I have a text file in which each line contains two "words" like this:
"(a+p(a|u)*h(a|u|i)*m)" "apehem"
"(a+p(a|u)*h(a|u|i)*a)" "correct"
"(a+p(a|u)*h(a|u|i)*e)" "correct"
First "word" is a regular expression pattern, second "word" is a real word. Both are double-quoted.
I want to search richTextBox3
for matches of first "word" of each line from the above file and replace each match with second "word".
I tried this (see below), but there is some error...
System.IO.StreamReader file = new System.IO.StreamReader(@"d:\test.txt");
string Word1="";
string Word2="";
lineWord1 = file.ReadToEnd().Split(" "); //Error
string replacedWord = Regex.Replace(richTextBox3.Text, Word1, Word2,
RegexOptions.IgnoreCase);
richTextBox3.Text = replacedWord;
Please advise. Thank you in advance!