各行に次のような2つの「単語」が含まれているテキストファイルがあります。
"(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"
最初の「単語」は正規表現パターンであり、2番目の「単語」は実際の単語です。どちらも二重引用符で囲まれています。
richTextBox3
上記のファイルから各行の最初の「単語」の一致を検索し、各一致を2番目の「単語」に置き換えたい。
これを試しましたが(以下を参照)、エラーがあります...
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;
お知らせ下さい。前もって感謝します!