![]() |
Languages »
VB.NET »
General
Intermediate
Regex TesterBy Harish PalaniappanA simple Regex Tester. The code also illustrates the simple usage of regular expressions in .NET |
VB, Windows, .NET 1.0, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||

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 be sometimes time consuming, especially for large input strings.
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.
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
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 attatched 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 already are conversant with simple .NET programming and the process of creating regular expression patterns, the Regex Tester might be all u need. ;)
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 1 Jun 2003 Editor: Nishant Sivakumar |
Copyright 2003 by Harish Palaniappan Everything else Copyright © CodeProject, 1999-2009 Web18 | Advertise on the Code Project |