Regular Expressions

A regular expression, regex or regexp (sometimes called a rational expression) is, in theoretical computer science and formal language theory, a sequence of characters that define a search pattern.

These are used in PNR Watcher in the Entry Trigger box (to pattern match an entry), in the Prompt for Input action box or the Matches / Does Not Match Pattern rule operator

The following contains useful information about Regular Expressions http://www.regular-expressions.info/tutorial.html

Entry Triggers

Rules can be written using Regular Expression triggers which allows users to define all sorts of trigger entries - outside of the standard END TICKET and QUEUE entries.

The above list shows some of the most commonly used Regular Expressions.

As an example. A rule administrator can write a rule against an availability entry. The rule logic would be;

/A.{4,5}LHR(JFK|MIA|IAD)/;

If Host Session Exists, display an alert saying “We have route deals on VS for this availability”, trigger only when an Availability Entry containing LHR to JFK or MIA or IAD is entered

This rule will now be able to display an alert to the user about your route deals if the user ever performs an availability from London to New York - this would prompt them to at all times try and sell VS on this particular route.

To explain this in simple terms
/ Start of pattern match
A Beginning of Availability Entry e.g. A10SEPLHRJFK
.{4,5} Any 4 or 5 characters for date i.e. 1SEP or 10SEP e.g. A10SEPLHRJFK
LHR Departure airport e.g. A10SEPLHRJFK
(JFK|MIA|IAD) Arrival airport i.e. JFK or MIA or IAD (use | "pipe" as or and () to group common items together) e.g. A10SEPLHRJFK
/ End of pattern match
; Finish pattern match

Certain characters (the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ), the opening square bracket [, and the opening curly brace { are reserved for special use in Regular Expressions
When these appear in a Galileo entry that you wish to match you must use a \ to show that this is a character you wish to match, rather than a character you wish to use for its special use in RegEx.

Another example. A rule administrator can write a rule against a Fare Quote entry, to trigger when consultant doesn't use a modifier ONLY FQ or FQBB. The rule logic would be;

/^FQ$/;/^FQBB$/;

If Host Session Exists, display an alert saying “Please consider other entries that can bring back more specific fares”, trigger only when user types FQ or FQBB. Allow FQ:P or FQBBS1-2 etc

To explain this in simple terms
/ Start of pattern match
^ Starts exactly with (use ^ caret marches at the start of the string)
FQ Fare Quote Entry e.g. FQ
$ Ends exactly with (use $ dollar matches at the end of the string)
/ End of pattern match
; Finish pattern match, then other entry (if more than 1 entry)
/ Start of pattern match
^ Starts exactly with (use ^ caret)
FQBB Fare Quote Entry e.g. FQBB
$ Ends exactly with (use $ dollar)
/ End of pattern match
; Finish pattern match

Final example. A rule administrator can write a rule against a Client File Move entry, to trigger when consultant typesCMT/NAVITAS1 or C*NAVITAS1. The rule logic would be;

/CMT\/NAVITAS1/;/C\*NAVITAS1/;

If Host Session Exists, display an alert providing client information, trigger only when user types CMT/NAVITAS1 or C*NAVITAS1.

To explain this in simple terms
/ Start of pattern match
CMT Client File Move Entry e.g. CMT/NAVITAS1
\ Back slash (as we know / is a special character start of entry)
/ / part of entry e.g. CMT/NAVITAS1
NAVITAS1 BAR title e.g. CMT/NAVITAS1
/ End of pattern match
; Finish pattern match, then other entry (if more than 1 entry)
/ Start of pattern match
C Client File Display Entry e.g. C*NAVITAS1
\ Back slash (as we know * is a special character match zero or more)
* * part of entry e.g.C*NAVITAS1
NAVITAS1 BAR title e.g. C*NAVITAS1
/ End of pattern match
; Finish pattern match

Pattern Matching

Regular Expressions are also used in the Matches / Does Not Match Pattern [P] section of Rule Construction.

In the above example we want to check that the DI.AC field in the booking matches the format required for our Back Office system - any alpha character 3 times, followed by any digit 4 times e.g. ABC1234

We can set the Matches Pattern as follows; /[A-Z]{3}[0-9]{4}/

/ Start of pattern match
[A-Z] One of the characters in the range A-Z
{3} Exactly three times
[0-9] One of the characters in the range 0-9
{4} Exactly four times
/ End of pattern match

The 'Prompt for Input' action has been enhanced to allow the specification of a pattern the users input must match to be accepted, so if the Account Code being asked for must be 2 digits followed by 3 alpha characters, rules administrators can now ensure this pattern is being adhered to by the user.

Previous Lesson: Rule Actions Explained Table of Contents Next Lesson: Navitas Expedia Integrator - Installation Guide