输入:This AbT5xYAppleUvW is a test.....
输入将是来自我没有控制的源的文件内容。如果有空格字符(换行符、回车、空格等),我需要用AbT5xYApple
替换为FruitApple
。是否介于AbT5xY
和Apple
之间。例如,AbT5xY Apple
或AbT5xY\nApple
也需要替换为FruitApple
。
注意到我在使用C#正则表达式
下列各点不起作用:
string input = Regex.Replace(input, "AbT5xY\S+AppleUvW", "FruitApple");
发布于 2017-08-07 20:55:39
在上面的注释中,使用以下模式AbT5xY\s*Apple
AbT5xY # "AbT5xY"
\s # <whitespace character>
* # (zero or more)(greedy)
Apple # "Apple"
https://stackoverflow.com/questions/45559297
复制