Click here to Skip to main content
15,887,936 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
}
//textBox1.Text = temp;


if (ReleaseCMD == "1")
{
    MessageBox.Show("Done","Successfully Replaced");
    ReleaseNew= string.Empty;
    ReleaseCMD = string.Empty;
    CharStore = string.Empty;

}
else
{

  ///Nothing.

}




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.
Posted
Updated 15-Sep-18 4:29am
v2
Comments
Patrice T 15-Sep-18 2:14am    
What is the question ?
Abrar Khan 15-Sep-18 3:34am    
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.
Abrar Khan 15-Sep-18 3:35am    
My code is not works for me. Is there any solution
Patrice T 15-Sep-18 3:53am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
Show sample input/expected output/ actual output, and explain how code don't work for you.
Abrar Khan 15-Sep-18 10:30am    
Thanks patrice for spend your valueable time for reply me. I edited my question

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900