Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Regex Tester

0.00/5 (No votes)
1 Jun 2003 1  
A simple Regex Tester. The code also illustrates the simple usage of regular expressions in .NET.

Sample Image - regexTester.gif

Introduction

The Regex Tester is an application to use for testing regular expression patterns on a test string, as we create the pattern, rather than testing it on the actual input, which may sometimes be time consuming, especially for large input strings.

Using the RegexTester

The usage is more straight forward. The input string is typed in the test string box, and the pattern is typed in the pattern textbox, as shown above.

Regular Expressions in .NET

Using regular expressions in .NET is pretty simple... using the regularexpressions namespace available:

Imports System.Text.RegularExpressions
' import the namespace

'instantiate the objects
dim oRegex as new regex("test pattern")

'use the object
If oRegex.IsMatch("this is the string to test on") Then
    msgbox "Match found"
else
    msgbox "Didnt find match"
end if

Points of Interest

The RegexTester with this article has a little nice feature for you to experiment. If the test string box is left empty, the application searches for a file teststring.txt (can be anything if the code attached is aptly modified), and if the file is found, uses the contents of the file as a test string. This feature comes in needy, when the input string / test string is large.

If you are already conversant with simple .NET programming and the process of creating regular expression patterns, the Regex Tester might be all you need. ;)

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here