For those who have been watching my Regular Expression Series, you know I use Expresso in the classes. I was very excited and proud to have Jim shoot me an email the other day. He seemed to enjoy the series and even gave me some pointers on how to use the product better. I thought I would share some of his insights with you. You will probably get better use from these comments if you have seen the first two parts of this ten part series:
Expresso is and always has been free. The release version of Expresso 3.0 is now on the web site.
Expresso can generate a text version of the tree structured analysis and can automatically put this into XML comments in the generated code. You can easily get back the original sample text by loading the sample project from the “File” menu, and you can start with a blank slate by clicking the “New Project” button.
My “Builder” and editing tools make it unnecessary to consult a reference sheet if you can’t remember the exact syntax of a negative lookahead or anything else. I think my “Analyzer” is second to none. I also have tools for code generation in VB, C#, Managed C++, and C++ CLI, for timing tests, for building and maintaining regex libraries, etc.
A question came up about differences between the “Validate” and “Run Match” tools. “Run Match” is easy to describe. It simply runs the regex against the full text in the sample window and displays all the matches. It is easy to understand what is happening and it is exactly what would happen if you put that text into the Regex.Matches() method. Unfortunately, this is not the best way to test validator controls, which are usually validating a single line of text. For these, it is helpful to have a list of matching and non-matching strings against which to test the regex. The “Validate” tool breaks the sample text into a collection of lines, stripping out the line termination characters, and running each line separately. It then shows whether the entire line matched, whether just a part of the line match, or whether none of it did. This gets rid of any annoying problems with properly matching the line termination characters, which typically will not be part of what is being validated.
I have found that one of the most confusing things using Expresso is the fact that the sample text, like any Windows text file, has lines terminated by a carriage return and then a line feed. If you have a “$” at the end of your regex, you better be sure that you match the line termination prior to the “$”. As you know, this is a real issue that you have to deal with in multiline text, but is a real point of confusion if you are targeting your regex for strings with no embedded line termination. I also address this by showing the non-printing text characters in the match results. For example, double-click the attached project file and press F5. Notice that it matches all three lines, as desired, but if I delete the “r?” the match won’t work because the carriage return will not get matched. If I use “Validate” it works either way.
(Note that the easiest way to delete the “r?” is to expand the Analyzer, select the appropriate line and push “Delete”, a simple example of the extensive editing that can be done in the Analyzer window. Watch what happens if you double-click or right-click a line in the Analyzer.)
No need to cut and paste in Notepad. Just save to a project file and later restore it from the list of recently used files in the “File” menu.
Sorry about the confusion of turning the “IgnoreCase” option on. This was not actually intended to be a default option. In fact Expresso sets the options however they were set in the last saved project file. Since the program first opens with a sample project, the options are set according to the first regex in the library stored in that file.
You may have been annoyed by the tooltips that kept showing in your demo. You can easily turn these off by unchecking the “Use Tool Tips Under Mouse Cursor” command in the “Help” menu.
You made an excellent point about the trouble that using * can get you into. This can be very confusing in debugging a regex. Try this in Expresso 3.0. All the NULL matches are shown and, with this release, below the results tree I show where the NULL match occurred by displaying the neighboring text with a pipe symbol show where the NULL match was.
Thanks Jim for all the insights and thanks to all the folks who are watching the series 🙂