Поделиться через


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.

Comments

  • Anonymous
    July 14, 2003
    The comment has been removed
  • Anonymous
    July 22, 2003
    Thanks for the new Version Eric... I look forward to pulling it apart ;-)
  • Anonymous
    February 13, 2004
    I've been through a decent number of regex toolkits, and I have to say, this is the best one I've seen yet.

    Pierre - It looks like the installer doesn't copy everything correctly. If you manually copy the directories included in the distribution zip file into the application directory alongside Regex Workbench.exe, the menus work properly.

    One thing that really bothered me was writing expressions while "Hover Interpret" was selected - If you used mouse navigation to move the cursor back into the expression, and the mouse drifted a pixel to either side, the group under the mouse would be selected. When I typed anything, it would overwrite the entire block of text.

    It wouldn't bother me that much except that the undo buffer only holds one change. Also (and there may already be one but I haven't found it yet), would it be possible to add a hotkey to enable/disable "Hover Interpret"?

    bc
  • Anonymous
    December 18, 2004
    Helpful For MBA Fans.
  • Anonymous
    August 24, 2006
    PingBack from http://blogs.infinite-x.net/2006/08/24/net-developers-take-a-look-at-project-anvil/
  • Anonymous
    January 21, 2009
    PingBack from http://www.keyongtech.com/608900-regex-help/2