我有类似的字符串
[any characters]{$\prime$}[any characters]$[any characters]{$\prime$}[any characters]$[any characters]
我想替换$\prime$
$"The second one" 里面的那个被替换为 \prime 所以replace的输出是
[any characters]{$\prime$}[any characters]$[any characters]{\prime}[any characters]$[any characters]
如何使用 Reqex.Replace 做到这一点
这是我使用的代码
trannsformContent = Regex.Replace(trannsformContent, @"(\$)(?<cont>.*?)(\$)\\prime(\$)(?<cont1>.*?)(\$)", @"${cont}\prime{cont1}$", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnoreCase);