Match and replace

When extracting identifiers, synonyms and descriptions from files, it is often necessary to use only a specific portion of an existing string and possibly modify it to maintain compatibility with other files. The match and replace pattern used extensively in the Stage 2 configuration files is intended to simplify this process and to remove the need to use one-liners to generate intermediate files with compatible naming.

The pattern used is to match a regular expression within the selected string and optionally replace part of this string using a second regular expression.

Match

The simplest case is to match the entire string:

/(.+)/

To match part of a string, either specify the pattern to match inside the parentheses, or specify a sting to exclude outside the parentheses:

/(\w+\d+)/
/(.+)-PA/

Replace

If specified, a second regular expression acts on the value captured during the match step and substitutes one of more characters:

/(.+)/ /-PA/-TA/