Possible Duplicate:
Count regex replaces (C#)
Is there any way to tell how many replacements a Regex.Replace(...)
call makes?
You could use the Regex.Replace Method (String, String, MatchEvaluator) overload and establish a count with your custom MatchEvaluator
.
You can always do this like so:
int count = 0;
string newStr = Regex.Replace(origStr, regexStr, m => { count++; return "replacement"; });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With