请教一下:
我用这个替换不了fc@
string Str = @"My QQC is Magci,QC short mgc. fc@ I like c sharp!"; 
Pattern = @"\bfc@\b";
Matches = Regex.Replace(Str, Pattern, "HHHH"); 但我把@放在中间就可以替换了,不知是什么原因string Str = @"My QQC is Magci,QC short mgc. f@c I like c sharp!"; 
Pattern = @"\bf@c\b";
Matches = Regex.Replace(Str, Pattern, "HHHH"); 
这样可以

解决方案 »

  1.   


    Pattern = @"\bfc@\b";
    //改为
    Pattern = @"\bfc@";
      

  2.   

    @\b \b单词边界,表示一侧为组成单词的字符,另一侧为非单词字符或者为空,而楼主的正则中,因为\b左侧不是组成单词的字符,所以要求它的右侧是组成单词的字符,而楼主的例子中显然不满足