string input = textbox1.Text;
Dictionary<string, string> map = new Dictionary<string, string>();
map.Add("AB", "x");
map.Add("Ab", "z");
map.Add("aB", "p");
string temp = input;
foreach (var entry in map)
{
string key = entry.Key;
string value = entry.Value;
temp = Regex.Replace(temp, key, match =>
{
bool isUpper = char.IsUpper(match.Value[0]);
char[] result = value.ToCharArray();
result[0] = isUpper
? char.ToUpper(result[0])
: char.ToLower(result[0]);
return new string(result);
}, RegexOptions.IgnoreCase);
}
This is my code...I use this for parse my small words. Like AB=x CB=z etc etc...
But my problem is - it can't understand lowecase and upercase (not case sensative)
Look I mapped :
map.Add("AB", "x");
map.Add("Ab", "z");
map.Add("aB", "p");
I mapped every AB,Ab,aB for different result.
But when i put AB,Ab,aB it just shows "x" !
But i want to show different result for eaches.
Where is my coding problem.
What I have tried:
map.Add("AB", "x");
map.Add("Ab", "z");
map.Add("aB", "p");