大家好:我需要使用 RexEx 匹配相似的单词。例如,如果我有一个包含“自治”之类的词的模式,它应该匹配“自治”这个词而不匹配“自治”。
示例代码:
void modify(string word)
{
string input = "This island is a colony; however,it is autonomous and " +
"receives no orders from the mother country, autonomy, N.";
string pattern = @",\s" + word + @"\s[v|n|adj]\.";//word = "autonomous";
Regex reg = new Regex(pattern);
string output = reg.Replace(input, ".");
}