Welcome to MSDN Blogs Sign in | Join | Help

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.

 

 

 

 

 

 

Published Monday, July 07, 2003 5:51 PM by ericgu

Comments

Tuesday, July 15, 2003 5:12 AM by Pierre Greborio

# RE: Regular Expression Workbench V2.0

When selecting "Library" menu item the application hangs: See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.IO.DirectoryNotFoundException: Could not find a part of the path "C:\Documents and Settings\Administrator\library". at System.IO.__Error.WinIOError(Int32 errorCode, String str) at System.IO.Directory.InternalGetFileDirectoryNames(String fullPath, String userPath, Boolean file) at System.IO.DirectoryInfo.GetDirectories(String searchPattern) at System.IO.DirectoryInfo.GetDirectories() at RegexTest.Form1.CreateLibrary(DirectoryInfo dirInfo, MenuItemCollection collection) at RegexTest.Form1.library_Popup(Object sender, EventArgs e) at System.Windows.Forms.MenuItem.OnPopup(EventArgs e) at System.Windows.Forms.MenuItem.OnInitMenuPopup(EventArgs e) at System.Windows.Forms.MenuItem._OnInitMenuPopup(EventArgs e) at System.Windows.Forms.Menu.ProcessInitMenuPopup(IntPtr handle) at System.Windows.Forms.Form.WmInitMenuPopup(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies ************** mscorlib Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll ---------------------------------------- Regex Workbench Assembly Version: 1.0.1279.37222 Win32 Version: 1.0.1279.37222 CodeBase: file:///C:/Documents%20and%20Settings/Administrator/Start%20Menu/Programs/Regex%20Workbench.exe ---------------------------------------- System.Windows.Forms Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll ---------------------------------------- System Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll ---------------------------------------- System.Drawing Assembly Version: 1.0.5000.0 Win32 Version: 1.1.4322.573 CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll ---------------------------------------- ************** JIT Debugging ************** To enable just in time (JIT) debugging, the config file for this application or machine (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled. For example: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the machine rather than being handled by this dialog.
Tuesday, July 22, 2003 8:34 PM by Darren Neimke

# RE: Regular Expression Workbench V2.0

Thanks for the new Version Eric... I look forward to pulling it apart ;-)
Wednesday, August 20, 2003 9:01 PM by Anonymous

# RE: Regular Expression Workbench V2.0

Friday, February 13, 2004 4:05 PM by bushidocoder

# re: Regular Expression Workbench V2.0

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
Sunday, June 20, 2004 7:04 PM by Cyrus' Blather

# Next gen editor architecture for VS

Sunday, June 20, 2004 7:21 PM by Cyrus' Blather

# Next gen editor architecture for VS

Thursday, July 01, 2004 6:09 PM by jaybaz [MS] WebLog

# Making regex less painful

Saturday, July 10, 2004 9:06 PM by Wintellog

# Cool Regex Stuff

Saturday, December 18, 2004 10:57 AM by MBA

# MBA

Helpful For MBA Fans.

# Mitch Milam&#8217;s Microsoft Discussions &raquo; Blog Archive &raquo; .NET Developers: Take a look at Project Anvil

New Comments to this post are disabled
 
Page view tracker