Regular Expression Workbench V2.0
I've finished a new version of my Regular
Expression Workdbench, and it's now available on gotdotnet.
If you use regular expressions on .NET, or you've heard about them but haven't really
tried them, this tool can help you a lot. If I do say so myself.
As an old Perl guy (in both senses of the word "old"), I've spent a fair amount of
time writing regular expressions. It's easy to try out a regex in Perl, but not so
easy in a compiled language like C#. I wrote the first version of this utility a couple
of years ago, and in the first version, all it did was let you type in a regex, a
string to run it against, and execute it.
Over time, it grew. The next version supported some fairly cool features:
- A menu with all the regex language options, so you don't have to remember what the syntax is for zero-width positive lookaheads.
Automatic creation of C\# or VB code based on your regex and the options you choose.
- Interpretation of regexes. Hover over a part of the regex, and the popup will tell
you what that part of the regex means. This is very useful if you're trying to learn
regex, or you don't remember what "(?<=" means.
- Support for calling Split()
This version adds a few more features:
- A nicer UI. Not a very high bar, given the previous design ("Who designed this UI? Vandals?") (5 points to anybody who knows who wrote that line...). A real menubar, a somewhat-pleasant grouping of controls, etc.
Library functionality. Give the regex you wrote a description, and save it away into a library, so you can open it up later, or show it off to your friends. Chicks dig a well-crafted regular expression.
- Unit tests for the interpretation features. Found 3 or 4 good bugs when writing the
unit tests. These tests will get better over time.
- Support for calling Regex.Replace(). Specify the replacement string, and you'll see
exactly what gets replaced.
- Support for calling Regex.Replace() with a MatchEvaluator. For the cases where you
can't do your replacement with a simple substitution string, the Regex class lets
you write a delegate. The workbench now allows you to write the function, which it
saves away, compiles, loads and then uses to call Replace.
Comments & suggestions are always welcome.