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.
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 SettingsAdministratorlibrary".
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.
Thanks for the new Version Eric… I look forward to pulling it apart 😉
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
Helpful For MBA Fans.
PingBack from http://blogs.infinite-x.net/2006/08/24/net-developers-take-a-look-at-project-anvil/
PingBack from http://www.keyongtech.com/608900-regex-help/2