March 19, 2010

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


View Comments: Comments (2) |

Comments


March 20. 2010 03:22
csharptest
Not that long ago I too was not comfortable with writing regular expressions.  I did some looking around and found a free tool called Expresso. It is a must-have for me now and has, over time, made me comfortable with using regex.  

http://csharptest.net/http://csharptest.net/


March 23. 2010 15:38
Phileosophos
You might want to look into a tool called the regulator. Here's the link:

http://sourceforge.net/projects/regulator/

It's a little tricky to figure out the interface at first, but think of it as an IDE for regex development and it's pretty cool.

http://phileosophos.com/http://phileosophos.com/

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading



Recent Comments

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.