DCSIMG
Back To Basics: Use Regular Expression Comments - Rotem Bloom's Blog

Rotem Bloom's Blog

Share knowledge on .NET and web development

News

About Me

Glad to help and share knowledge on .NET and also huge fan of Dream Theater.

Contact me via messenger

View Rotem Bloom's profile on LinkedIn

Dream Theater Pics

Blogs I Read

Back To Basics: Use Regular Expression Comments

Regular expressions are much easier to understand if you use the following syntax and comment each component of the expression by using a number sign (#). To enable comments, you must also specify RegexOptions.IgnorePatternWhitespace, which means that non-escaped white space is ignored.

Regex regex = new Regex(@"

                        ^           # anchor at the start

                       (?=.*\d)     # must contain at least one numeric character

                       (?=.*[a-z])  # must contain one lowercase character

                       (?=.*[A-Z])  # must contain one uppercase character

                       .{8,10}      # From 8 to 10 characters in length

                       \s           # allows a space

                       $            # anchor at the end",

                       RegexOptions.IgnorePatternWhitespace);

 

Enjoy,

Rotem

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: