Testing Regexes

Recently I had to implement a Regular Expression (Regex) to validate that a property was a certain length. The validation rule was:

String should be  3-4 characters in length, first 3 must be numeric, third must be greater than 0. and fourth (if provided) must be alphabetical.

Since I rarely write Regexes, I generally catch up with the .NET Cheatsheat, or reference my copy of Mastering Regular Expressions. There is even a free tool online (created using Adobe Flex), that allows you to test and create Regular Expressions in real time.

Enjoy.

 

[Author’s Note: This was actually written on 2/25/2010. I went looking for it to find the link to the Adobe flex tool and realized that I’d never published it. I’m publishing it now, especially because I goofed on the original requirements and have to refine my regex.]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s