RegexStudio Documentation

The premier Regular Expression development environment for .Net

Creating Regular Expression Assemblies

Regex Studio gives you the power to compile your own Regex Assemblies. This is a little known feature of .Net, in which a regular expression can be compiled and stored in a dynamic link library (DLL). This allows for the greatest speed, because the regular expression is pre compiled, and it also allows for separation of regular expression logic. For larger projects, you can store all your regular expressions in a separate assembly. With Regex Studio you can take care of creating, editing, maintaining and compiling your regular expression library.

This is what the Compile Tab looks like:



Creating a Project

In order to create a dedicated regular expression library, you must use Regex Studio in project mode. Choose the New Project from the File menu. You can then choose the “Save As” option to provide a default name for your project.

Edit and test your regular expressions as you normally would. Once you have completed your testing, use the “Add To Library” feature from the Tools menu, or click on the Ad To Library link above the regex field. The Add To Library dialog box is displayed, which has the name, regular expression, notes and sample text on the first (“General”) tab. The second tab allows you to set all the Regex options and choose if the regex is to be included in the compiled library (more on this in a moment).

In order to add a regular expression to a library, it must contain a name. This name is how you reference it in your code, later on.

Once you have added a regular expression, the Compile tab will automatically be selected. You’ll see your new regular expression listed in the Inclusion List on the left hand side. A checkbox next to the item allows for a specific regex to be included in a compiled regex. This relates to the “Include in compiled library” checkbox in the Add To Library dialog box. You can have multiple regular expressions in a library, however you might not want to include all of them in a compiled assembly. Only the checked items are included in the compiled regex.

Setting Assembly Options

The right side of the Compile tab contains options for the creation of your regular expression assembly. This includes the following information:


You will need to enter all of the above information in order to create your regular expression assembly.

Compiling the Assembly

When you are ready to create the assembly, choose the “Compile Assembly” option from the File menu, or click the Build button in the lower right corner of the Compile tab. The regular expression assembly will be created and put into the specified folder.

If you desire, you can click the “Run NGEN on compiled assembly” which will automatically run the NGEN tool (used to execute the just in time compiler against the assembly, and store the Intel byte-codes in the assembly at runtime, in addition to the regular .net instructions). If you choose this option, a command prompt will appear momentarily when you build the assembly.

You’ll probably also want to choose the “Save Project” from the File menu in order to save all your information about the generated assembly. Later you can reload the project file and edit the project.

Automating Regex Assembly Builds

If your team uses Regex Studio to generate assemblies, you might wish to call Regex Studio from within your build script. You can achieve automatic use (without displaying the GUI) by using the following format:

RegexStudio.exe filename.rgx /build

In this case, you do not need to specify the extension (“.exe”, you must include the full filename for your project file (“filename.rgx”) and then include the /build keyword at the end of the command line, in this order.

By doing so, and assuming the correct assembly information has been entered in the original project file, the assembly will be generated without showing any graphical user interface.

Note, you can also use the format without the /build option, in which case Regex Studio starts up and loads the specified project file.