RegexStudio Documentation

The premier Regular Expression development environment for .Net

Creating Regular Expressions

The first power in Regex Studio is in its ability to create and edit. We’ll start out by looking at all the tools that help you write your regular expressions.

General Information

Regex Studio can operate in two modes. The first mode is in scratchpad mode. This allows you to type regular expressions, set options, test them and see your regular expression analyzed. This is the most common mode to use Regex Studio in. In this mode, the main window title bar will refer to the filename “Untitled”.

The other mode you can operate in is project mode. This mode is required for advanced usage when you are creating and compiling Regex assemblies. In this case, you will see the project name specified in the title bar. You work with a project by choosing the items on the File menu, including “New Project”, “Open Project”, “Save Project” and “Save Project As”. You only need to use a project when compiling Regex Assemblies.

Working with Fields

Various fields that you enter are persisted between sessions, such as name, regular expression, notes, sample text, replacement text and set options. To reset these fields click the Clear link next to the field to empty an individual item. You can also choose the “Clear All Workpad Fields” from the Edit menu, and all fields will be emptied.

Moving Between Tabs

The tabs displayed below the toolbar signify the areas of operation. Going from left to right, these are: Create, Options, Test, Code, Compile and History. The View menu allows you to choose a different tab using the keyboard, rather than the mouse. There are menu items for each tab.

You can increase the size of the main window and the fields inside will expand accordingly. This makes it easier to see more of your work, especially when working on a large monitor.

Using Dynamic Help

The dynamic help system provides instant feedback about all aspects of the Regex Studio environment. The dynamic help window pane is always in the very bottom part of the main window. As you move the mouse cursor over user interface elements, the dynamic help window displays information about the specified feature. It also persists this information until you hover the mouse over a different field. This gives you the chance to read more about the help item.

The following pictures demonstrates Dynamic Help being displayed in the Options Tab, while the mouse cursor (not pictured) hovers over the ECMA Script checkbox:


 


Entering Regular Expressions

On the Create tab, the Name field gives you a name that you can reference a regular expression. This is optional in scratchpad mode, and in project mode is the name used to refer to the regular expression in code. The Name cannot have spaces, so if you enter them, the spaces will be removed.

The Regular Expression field on the Create tab is where you enter your regular expressions. As you type the expression, you will see various parts displayed in different colors. As you complete regular expressions, the Analyzer (below the regular expression) will display what the individual parts of the regular expression do.

As you type, any syntax errors are highlighted with a keyboard tooltip. If you hover the mouse over a regular expression, that part of the regular expression will cause a tooltip to appear describing what it does.

The following diagram illustrates the Create Tab:



Introducing the Expression Builder

While the cursor is in the regular expression field, the “Expression Builder” button can be clicked, which shows a cascading menu of regular expression options. You can also choose the “Expression Builder” menu item from the Tools menu. If the cursor is not in the regular expression field, the expression builder button and menu item is disabled.

Many of the menu items insert regex fragments directly. A number of the items display a dialog box, that allow you to enter all the parameters about a regular expression, and when you complete the dialog box, the regular expression is created from your input and inserted into the regular expression field.

You can try it now by choosing the “Character Shortcuts” menu item and then choosing the “ASCII Chart” option. You’ll see the “Insert ASCII Character dialog box, which displays as ASCI chart, and lets you click on the symbol you would like to enter. You also have the choice of using hexadecimal or octal representation (default is hex). The dialog displays the regular expression fragment. When you click the “Insert” button, the fragment is entered in the regular expression field. At the same time, The Analyzer will provide an English explanation for the regular expression fragment.

If you are editing a regular expression, ensure that the cursor is placed at the place you would like regular expression information to be entered. The regular expression text is filled in at the place of the current cursor.

We’ll talk more about all the features of the Expression Builder later.

The Analyzer

The analyzer, at the bottom of the Create tab interprets the meaning of your regular expression. It breaks complex expressions down into their component parts. It only shows the parts of the regular expression it understands. If you have entered improper regex syntax, it will not show up in the analyzer. However, you will see a keyboard tooltip describing the error.

The following illustration shows the analyzer text for a sample regular expression:


 


Showing the Gallery

The Gallery displays a list of predefined regular expressions. Click on the “Show Gallery” link above the regular expression field or choose the “Show Gallery” item from the “Tools” menu.

The gallery lists a number of predefined regular expressions. You need to highlight one in the list on the left. You’ll see it’s name, any associated notes, the regular expression itself, along with sample text.

The following picture shows the Regular Expression Gallery dialog:



After you have selected a predefined regular expression from the left-hand column, click the OK button. If you have been typing any regular expressions, you might get a warning that the system is about to overwrite them. When you click the Yes button, the four fields associated with the gallery entry will be brought into scratchpad mode. You can even go to the Test tab, and already have sample text to test the regular expression.

Adding to the Library

If you are creating an regular expression assembly, it means you are creating a library of regular expressions. When you have perfected a regular expression, you can add it to the library by clicking the “Add To Library” link next to the regular expression fielc, or choose “Add To Library…” from the “Tools” menu. A dialog will appear, allowing you to confirm all the options associated with that regular expression. When you add it, you’ll be switched to the Compile tab, and you’ll see your new regular expression listed in the list in the left.
 

The following pictures shows the General Tab of the Add To Library dialog box:

The following pictures shows the Options tab of the Add to Library dialog box: