# Regular Expression Tester

This panel allows you to test a regular expression against sample data and when appropriate variable and named variable. The panel can be run as a stand alone window, from the Regular Expression action statement, from the Compare Text statement, from the Multi Field Editor and fom the main window and database filter controls.

When opened as a stand alone window, the settings and content are loaded from the application saved values.

When opened elsewhere, settings are imported from the calling process. In this case, the test data is only preserved until the caller is closed. If no content is available for a caller, it will be loaded from the application saved values.

Depending on what process opened the panel, various functionality may be disabled to maintain the intent of the calling function.

Both the Regular expression and Replace template fields have a context menu submenu to assist in the entry of relevant escape sequences. Note that only the most common sequences are displayed. The escape sequences that are valid are dependent on the caller. When opened as a standalone window or via an action statement, track variables and named variables may be escaped.

Escape sequences which are not valid for the context will be ignored and passed through to the regular expression parser. Context menu items are available to assist with escape sequence insertion.

Typically, all regular expression meta characters which may be inserted by the substitution will be properly escaped so that the inserted text is treated as a sequence of literal characters. If for any reason you want to save the actual regular expression sequences to a variable you must tell the application that you do not want the inserted contents to be escaped. Both the regular expression and replace template fields have associated options called Do not escape inserted variable contents. The term variable applies to both Variables and Named Variables.

There are four functions which might be available:

Replace
  The matches are replaced with the evaluated Replace template. The destination field will contain either the initial or modified source field.
Return Matches
  The matches are returned in the destination. If more than one match was made, the returned matches will be separated by the default list delimiter (\~). This function is useful when you want to extract information from a field.
Return Ranges
  Each match is returned as as range specified as location,length. Note that the locations are relative to the source string after variable escape sequences have been replaced. If more than one match was made, the returned ranges will be separated by the line feed character for clarity reasons. Note that when executed in an action, a default list delimiter (\~) is used to separate ranges.
Return Ranges+
  This is the same as Return Ranges, except that capture group ranges are also returned. For every displayed range the format is:
  range of match{/range of capture group 1}{/range of capture group 2}...

You specify whether you want to match all occurrences, only the first or only the last. You can also select case insensitivity.

The Show RegExp button will display the contents of the Regular Expression field in the Results field as it will be passed to the regular expression parser. The Show Template button will do the same for the Template field.

Extract Variables will scan the Regular Expression and Template fields looking for escaped variables. Any found items will be displayed in the table at the top left of the window. Items which were already present will not have their values changed. You can edit the contents of the displayed variables. Note that the values are only updated when Extract Variables is pressed. The table's context menu can be used to clear all content.

The Test button will perform the specified function against the data in the Source field. The results will be displayed in the Results field. The source field will have each match alternately highlighted in yellow or light blue. The Clean button can be used to remove the highlighting from the source field.

If the panel is closed by the Save button, all content and settings will be saved to either the calling Regular Expression statement or the application's saved settings. Note that Save is implicit if the window is closed.

When run as a stand alone window, the Discard button will close the window clearing all retained content and settings. When elsewhere, the Discard button will close the panel, only preserving the variable and source content, not the settings.

The text fields and table respond to Font>Bigger and Font>Smaller.

More information on regular expressions may be found at:

Regular Expression Metacharacters

Regular Expression Operators

Regular Expression Replace Template Format

Regular Expression Flag Options