Say I have A Compiled Regex object :
public static Regex myRgx = new Regex(@"[\d]+",RegexOptions.Compiled);
Now let's say I'm reading large strings into the string variable SS , And then I use my Regex object to replace all matches within that string
myRgx.Replace(SS,"($&)");
Question: Does .Replace internally use a StringBuilder to do the work , much like what happens in String.ReplaceAll() ?
And if it doesn't is there a way to get around this ?
Update :
I don't know if it's ok to ask another question as an update to the original question .. feel free to edit this out if it's not ok.
Question 2 : What if I need to preform a chain of replacements , Using multiple Regex objects, As in:
string input = "Some LARGE string";
input = rgx1.Replace(input,"substitution1");
input = rgx2.Replace(input,"substitution2");
input = rgx3.Replace(input,"substitution3");
I'm writing a morphological analyzer ,So the regex objects need to be kept separate ,And replacements need to be done in a certain order as in the code above. The number of regex objects is large and we're talking Gigabytes of text, So passing a new string object, every time a regex object is done replacing ,Isn't really an option here.
Any Suggestions?