Hello All,
I have a project with this code:
Dictionary<string, string> map = new Dictionary<string, string>();
map.Add("FB", "facebook");
map.Add("gg", "Google");
etc etc
and in textbox1.text changed
<pre>
se += textbox1.text;
string temp = se;
foreach (var entry in map)
{
char[] result = value.ToCharArray();
return new string(result);
}, RegexOptions.Compiled);
}
textBox1.Text = temp;
it is full code of my program.
When i type in textbox1.text= hellofb it instant replaced to hellofacebook
but i want :
when i type - hellofb it works. it replaced to : hellofacebook in textbox. Works fine.
but but i want before replace "fb" or "gg" or etc (dictionary mapped)i want it show me a message with it's position(from textbox) and it's length.
What I have tried:
For use of foreach : i did this :
private string CharStore;
private string SeqLenth;
private string ReleaseNew;
string ReleaseCMD;
string temp = textbox1.Text;
foreach (var entry in map)
{
string key = entry.Key;
string value = entry.Value;
temp = Regex.Replace(temp, key, match =>
{
SeqLenth = key.Length.ToString();
ReleaseCMD = "1";
char[] result = value.ToCharArray();
return new string(result);
}, RegexOptions.Compiled);
}
if (ReleaseCMD == "1")
{
MessageBox.Show("Done","Successfully Replaced");
ReleaseNew= string.Empty;
ReleaseCMD = string.Empty;
CharStore = string.Empty;
}
else
{
}
Now -
I need finally -
i want before replace "fb" or "gg" or etc (dictionary mapped)i want it show me a message with it's position(from textbox) and it's length.