Tuesday, November 04, 2008

Regular Expressions


... is a tool which helps you quickly put together regular expressions.

Get it from: http://tools.osherove.com/

Download it. Run it.

I have version

In Text Edit mode, enter a value such as 0.25

Go into Regex Edit mode, the background will turn blue.

Do not highlight the text, just right-click it.

Select one of the options (e.g. Decimal number).

The resulting expression is ^-?\d+.\d+$

Click the Generate button, you get .Net code you can use.

I used this regular expression as follows in my form validation:

if (!System.Text.RegularExpressions.Regex.IsMatch(PassMark.Text.Trim(), @"^\d+\.\d+$"))
error = "Pass Mark must be a number";

The Regulator

... is from the same developer, covers the same ground but is a more full-fledged product. It's also free, which is really amazing.

How to use it - this is explained in the help - quick start.

The only thing that got me was I started typing my input in the box intended for the external file browse bottom-left. Type the input in the white area below.