« Basic web request & simple spider patterns | Main | Enabling Windows Explorer to search in source files »

Getting started with Regex pattern

private static RegexOptions regOpts =

  RegexOptions.Singleline |           // Otherwise “.” doesn’t match newline.

  RegexOptions.IgnoreCase |           // Ignores case of literals in pattern.

  RegexOptions.ExplicitCapture |       // Keeps unnamed parens from adding to groups.

  RegexOptions.Compiled |             // Trades startup time for speed.

  RegexOptions.IgnorePatternWhitespace;    // Allows comments and spacing in pattern for readability.

Regex re = new Regex(@"T(?<tape>\d+)\s+(?<from>\d+-\d+-\d+)\s+to\s+(?<to>\d+-\d+-\d+)\s*", regOpts);

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)