I have used Visual Regexp by Laurent Riesterer. It is a tool for constructing and testing regular expressions written in Tcl/Tk. I found it quite useful when writing the p2t.py script for PAGE.
Since I was debugging a new version of PAGE at the time, I decided that I would rewrite a subset of Visual Regexp in Python. My program is called 'vrex'. The reasons for writing it were (1) it thought it would be a good example of PAGE that would illustrate several important usages of tkinter - especially the application of different colored text in a text box. (2) Since Visual Regexp is a Tcl/Tk script it utilizes the Tcl regular expression processor which is necessarily different from the Python regular expression support and so a python programmer should test his regular expressions using the python regular expression support. (3) Visual Regexp has absolutely no documentation which is disgraceful but all too common with open source software. Since I wrote the python tool, I know how it works and can document it as I am doing here. This program is based on Visual Regexp and even uses the same colorization algorithm.
Visual Regexp provides a mechanism for creating the candidate regexp. However, I never figured out how it works (no documentation) so I couldn't put it in my program.
All that is needed is Python 2.7. Or if you are using Python 3.1 that is all that is needed.
Merely download vrex.tgz and untar it with
tar -zxvf vrex.tgzThe following command will execute the program:
python vrex.py
The program GUI looks like:
.
In normal usage, one loads a sample and a regular expression and experiments with incrementally changes both and testing by hitting the go button. When you are satisfied you can save the regular expression or put it on the clipboard by selecting the characters that make up the regular expression.
You can also enter a whole file of sample strings using File->Load Sample. In that case, when you select Go, the regular expression candidate will be applied to each line individually in the sample and the sample will be colorized accordingly. Obviously, you can add build a set of samples by adding them to the sample window and saving the sample to a file.