If anything can drive this Irishman into a fit of cursing, it's the need to create a regular expression quickly. With a little application, I know I could learn to create them myself but I figured some time back that the frequency with which I use them would not equate to the time invested in the study. So, I either have to rely on ones that I have, and can never locate, or turn to a good tool.

Well, I was reading Professional ASP.NET 3.5 in C# and VB by Scott Hansleman and others recently when I saw mention of a Regular Expression Editor in VS 2008. This was news to me! Then I noticed a regular expression facility in the Find and Replace tool (CTRL-F); how long has that one been around? Anyway, it was just what I needed for some basic regex's for email and phone numbers.

VS 2008 Regular Expression Editor


The only problem is trying to find the thing... they couldn't have hid it better if they tried. First, you have to be in design view to begin to locate it. Do people actually use design view? Then you have to refer to the control's properties window and click on the button next to the ValidationExpression property to launch the editor. Obvious, huh? :-|

VS 2008 Regular Expression Editor


Granted, it's pretty basic but if you're in a hurry this will save you some Googling time! I wonder is it possible to extend this tool to add in one's own custom regex's for reuse?

One more thing: Scott's book is a great reference with over 1600 pages of info. I have only two gripes about it: 1) If you read it in bed you'll need a hoist to avoid the hernia, and 2) The entire book is based on the Web Site template. What were they thinking of?

Comments (5) -

Amgad Suliman
Amgad Suliman U.A.E.
11/4/2008 11:18:34 PM #

Hey Anthony, I dont use regular expressions much too, so I rely on http://regexlib.com/ for the job, check it out it has all the standard stuff you might need. And by the way this is not my site I just thought you might find it useful.

agrace United States
11/4/2008 11:55:01 PM #

Thanks for the link Amgad Smile

Adam ┼╗ochowski
Adam ┼╗ochowski Canada
11/5/2008 5:30:08 PM #

For the love of god, do not validate emails using regexp!

The provided example will pass many invalid email, while fail many valid emails.

Emails are not simple to parse. Read RFC 2822. Or best yet, checkout one of the most standard compliant email parsers. Perl's Email::Valid module :


Kind regards

agrace United States
11/5/2008 5:50:57 PM #

Hi Adam,

The main thrust of the post is about the tool itself and its use for "general purposes". That said, you make a very valid point and I feel guilty for promoting a lazy approach to data input validation. I think I'll come back to this in another post and outline a better practice!!

Thanks for pointing that out Adam,
Anthony Smile

building hardware
building hardware People's Republic of China
9/30/2009 3:28:42 PM #

Thanks for sharing!

Pingbacks and trackbacks (2)+