Comment your regex scripts
.NET Regular Expressions allow you to embed comments and whitespace within pattern strings making them clearer to read (because of the whitespace), and easier to maintain (due to the modularity).

To use this feature you must turn on the RegexOptions.IgnorePatternWhitespace flag.  This can be achieved either by using the RegexOptions enumerated datatype or, via the (?x) mode modifier.  Therefore the following two examples are functionally identical:

Regex re = new Regex( 
        @"           # This pattern matches Foo
            (?i)     # turn on insensitivity
                     # The Foo bit
            \b(Foo)\b "
        , RegexOptions.IgnorePatternWhitespace ) ;


    Regex re = new Regex( 
        @"(?x)
                    # This pattern matches Foo
            (?i)    # turn on insensitivity
                    # The Foo bit
            \b(Foo)\b "
        ) ;
Language C# / Tagged with regex