Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

Using Regular Expressions When Editing Code in Enterprise Guide

You can use regular expressions when editing code in Enterprise Guide. This feature – available since EG 4.3 - enables you to do some things that would not otherwise be possible. Compared with what is available in the PRX functions, the regular expression syntax is less powerful, but easier to understand.

Using regular expressions when editing code in Enterprise Guide

Here the code for an EG Query Builder node is open in the editor, and "Edit", "Find" has been selected from the menu. The "Regular expression search" box has been ticked. Clicking on the arrow control to the right of the “Find text” box has resulted in the display of a summary of the available regular expression syntax.

The search string that has been entered is “bq”. Here “b” indicates a word boundary, so this string will match a letter Q at the beginning of a word. As the screenshot shows, the Q of “WORK.QUERY_FOR_CARHIRE_0001” has been found.

Several other useful metacharacters are introduced by “”. “w”, for example, will match any “word character” i.e. any character that is valid as part of a SAS name i.e. any alphanumeric character or the underscore “_”. This can also be written as [a-zA-Z0-9_], using the “set of characters” syntax in the list displayed. Such a character set can be negated using “^” at the beginning e.g. [^A-Z] will look for any character which is not an upper-case letter.

“^” is also used as an “anchor” denoting “start of line”. “$” is the anchor denoting “end of line”.

The “repeat count” symbols “*”, “+” and “?” always follow the character or subexpression they apply to. Beware of thinking of “*” as meaning “any number of times”, unless you're going to remember that “any number” includes zero.

Here are a few more examples of regular expressions you might want to search for:

• /*.**/
• Mr(s)?
• Mr|Mrs
• [^;s]s*$

The first of these will find comments in the “/*...*/” style, the “.*” in the middle meaning “any number of characters”. The other two asterisks each have to be preceded by the escape character “” to indicate that they are to be taken literally, rather than interpreted as repeat counts.

The second will match either “Mr” or “Mrs”, the “?” indicating that the subexpression “(s)” can appear 0 or 1 times. The third expression shows an alternative way of achieving the same result, using “|” which means “or”. (“Alteration” in the syntax summary – see screenshot - may perhaps be a misprint for “alternation”.)

The last one looks for lines that don't end in a semicolon. “[^;s]” matches any character that is neither a semicolon nor whitespace, “s*” matches any amount of whitespace (including none), and “$” anchors the expression to the end of a line.

Similar facilities are available in the Enhanced Editor in Display Manager.