Here is something that you may not be aware of. In .NET, if you use regular expressions, your code would perform much better if you minimize the times when you instantiate a Regex object.
For example, if you have a regular expression that you use repetitively throughout your code, you should construct the Regex object once and reuse it throughout your code. You'd be surprised how much overhead the Regex constructor requires.
Additionally, you should always pre-compile your regular expressions as well.
Regex rx = new Regex(@"\b(?<word>\w+)\s+(\k<word>)\b", RegexOptions.Compiled);
posted @ Monday, December 01, 2008 7:23 PM