When writing a software, you may need to use regular expression to filter some string values or to validate some input strings. It is quite troublesome to test the correctness of the regular expression pattern that you have designed. You will need to compile you source code, execute the compiled binary, perform some steps until to the point that make use of the regular expression. It takes a lot of time to do the trial and error especially if you are not very familiar with regular expression.
I have wrote a regular expression test tool for my own use and I also uploaded the tool to this web site so that everyone can use it. It is a php page that simply takes two parameters: the regular expression pattern and subject. The two parameters are then passed into a php function called preg_match(). From the returned value:
- if it is false, then the regular expression pattern is not valid;
- if it is zero, then the subject does not match the regular expression pattern
- if it is larger than zero, the subject matches the regular expression pattern
You can find the Regular Expression Test Tool here.
Example of regular expression pattern:
Leave a Reply