Regular expressions are powerful. There's no doubt about it. The .NET and Perl-derived implementations in particular are rich and capable. For the most part regular expressions are there to save you time from parsing text the hard way. But if you're spending more time bending regular expressions to your will to accomplish something that could be done more easily and efficiently with procedural code, then that kind of defeats the purpose. I've wanted to write this article for awhile. Then today I stumbled across this StackOverflow question which is a prime example where the procedural solution was actually quicker & easier to write, more understandable, and more efficient. Your ability to identify these situations will improve naturally with experience. But I thought I'd list a few good & bad scenarios for regular expressions... Good Data validation can be done easily and concisely with regular expressions in most cases. Good Syntax highlightin
Dedicated to the online C# regex tester at regexhero.net