【问题标题】:Replace part of word with regexp用正则表达式替换部分单词
【发布时间】:2015-09-03 19:18:42
【问题描述】:

如果replaceString 不是以“@”开头,我需要替换单词中的replaceString

例如:

replaceString - replaced to : replacedString
abc.replaceString - replaced to : abc.replacedString
abc.@replaceString - NOT replaced

我正在尝试使用@"(?!@)replaceString$" 之类的东西,但它无法正常工作。

【问题讨论】:

    标签: c# asp.net regex regex-negation


    【解决方案1】:

    使用后视而不是前瞻:

    (?<!@)replaceString$
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      • 2020-01-06
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 2010-09-27
      • 1970-01-01
      相关资源
      最近更新 更多