arschr wrote:
There once was a programmer who was trying to solve a problem. He decided to use regular expresions to solve it. Now he has two problems.
LOL
I like regexps for the fact that you can do things with them which otherwise would take a full parser. (afterall, it's an NFA lexer )
For 1.0.2005.1 for example, the name overwriting for procs has been enhanced, so I needed to centralize the routines. I moved to a regexp to find the elements in the various ways a proc name could be formulated. Check it:
Regex procNamePartFinder = new Regex(@"((?<catalogName>\[[\w\.]+\]|\w+(?=\.)).)?(?<schemaName>\[[\w\.]+\]|\w+).(?<procName>\[[\w\.]+\])", RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
Impossible to read, but it works .
The syntaxis is absolutely horrible, you need trial/error and testcode to get it working. But once it works, it's great