Test Your Regular Expressions with RegexpBench

Download RegExpBench.zip I created this little utility a while ago. It is a work bench for creating/validating regular expressions. You can use it to create and test your regular expressions and can also use it to generate C# or VB.Net code (experimental). Grammar While you can use regular expressions directly in the input window (the upper-left window), you can take advantage of using variables to simplify each block of regular expressions and build larger ones. This is especially useful when you are creating complex regular expressions. The variables are referenced using "%". To create a regular expression program that can be recognized by the RegexpBench, you will need to add the following directive at the beginning of your code (also see image below) : .RegexProg

Regular Expression Work Bench

Then you can use variables to define each portion of the expression. To refer to the variable, you need to pre-pend it with "%". All variables are displayed in blue. Usage You can put your validation test contents in the lower input box (also you can load it from file by clicking "Load From File". You may also choose your validation options from the list on the left. To run the test, press the "play" button on the tool bar, Any recognized results will be marked underlined in red. Note, the validator does not stop at the first match. All matches are displayed (depending on the options), you need to pay attention to the underlines to figure out whether the match(es) found is one or multiple. for example : This is a test is one match and This is a test are four separate matches. When the code is run, the upper-right window shows the generated regular expression (note, this will be the same as the expression you inputed if you are not using the .RegexProg directive.)


Be Sociable, Share!

Leave a Reply