Regular Expression Coach
Regex Coach is a free cross-platform program that you can use to learn and work with regular expressions in a visual environment.
Regular expression can be used to identify strings of text. They are written in a formal language that looks hard to understand on first glance but follows strict rules. Most users associate regular expressions with programming languages, and while this is surely a dominant area, regular expressions are supported in text editors and other tools as well. One of the most popular is probably grep in Linux.
Regex Coach
Regex Coach is an excellent software program to learn regular expressions using a graphical user interface and real-time results directly in the interface.
The interface itself is divided into two display panes: the first acts as an editor for regular expressions, the second holds a sample text which highlights matches based on the regular expression entered in the first. You can paste sample text into the second pane, or type it instead.
Below those two panes are tabs and buttons that provide additional functionality.
To test a regular expression, you'd do the following. You add a sample text to the target string field via copy and paste or by typing it directly.
Once the text is there, you add the regular expression. The program highlights matches automatically as you type which makes it easy to craft the right expression for the sample text. When you edit the regular expression or the text, results are automatically adjusted as well.
Invalid entries are displayed automatically as a status message. The program will for instance notify the user if a bracket has not been closed which would make the expression invalid.
Verdict
What I like about the program in particular is the info field. It explains the regular expression that you have entered so that you can adjust it based on that as well.
The remaining tabs are also useful. Tree divides the expression into different parts, the replacing and splitting text options act like Perl's substitution and split operators, and the step tab allows you to see the regular expression at work.
The Regex Coach is a learning by doing tool for learning or verifying regular expressions. There is still need for a documentation on regular expressions like this one.
While it is useful to learn regular expressions, it can also be used to debug expressions or create new ones that include testing to make sure they work properly.
If you prefer to use an online tool, or are not using Windows, then you may want to try RegExr, a free service that offers a similar feature set but online.
Mohamed Shafi: Thanks. This one works a little better for someone with very little regex experience.
There is another similar one . You can find it here
http://gskinner.com/RegExr/
This has both an online and desktop version. I use this.
Speaking of Perl saving the day, you can create a regular expression with 9 lines of Perl code.
#!/usr/bin/perl
while () {
chomp;
if (/YOUR_REGULAR_EXPRESSION_GOES_HERE/) {
print “Matched: |$`$’|\n”;
} else {
print “No match: |$_|\n”;
}
}