The best and most efficient solution for your time is to try the simplest approach first: forget the StringBuilder
and just use Regex.Replace
. Then find out how slow it is - it may very well be good enough. Don't forget to try the regex in both compiled and non-compiled mode.
If that isn't fast enough, consider using a StringBuilder
for any replacements you can express simply, and then use Regex.Replace
for the rest. You might also want to consider trying to combine replacements, reducing the number of regexes (and thus intermediate strings) used.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…