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.
[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.]