Mention should be made here that refernces can be made of numbered and named capture groups within the replacement string.
For example:
Let's say you wish to add double-quotes around all words.
Given this RegEx pattern:
(\w+)
You can add double-quotes around all words by referencing the numbered capture group like this:
C#:
string outputStr = rgx.Replace(inputStr, "\"$1\"");
VB.Net:
Dim outputStr AsString = rgx.Replace(inputStr, """$1""")
Given this RegEx pattern:
(?<word>\w+)
You can add double-quotes around all words by referencing the named capture group thusly:
C#:
string outputStr = rgx.Replace(inputStr, "\"${word}\"");
VB.Net:
Dim outputStr AsString = rgx.Replace(inputStr, """${word}""")