C# how to use Regex.replace, to replace all the pattern matches with the target string
Y开发者_开发知识库es, I want to search and replace all the occurrences of the pattern and replace them with a target string. I am trying to use Regex.Replace(src, pattern, target), is there a flag like \g to put in pattern to make it work, or what?
There is no \g
or concept of a global search, as the .NET Regex
class is global by default. In other words, it should just work, assuming you've written your regular expression properly.
You might want to test it in Regex Hero and then once you've got it working click the .NET
button at the top to get the code with properly escaped strings.
精彩评论