Regular expressions
Use regular expressions as a value for your step properties to check whether a search value contains a string that matches the regular expression.
API simulation uses the .NET Framework syntax for regular expressions.
Define regular expressions using the syntax {REGEX["<regular expression>"]} with the Verify or Trigger step properties.
In this example, you run a service named Service03:
-
With the trigger inbound step property, the service waits for a message that contains telephone numbers in various possible formats as the value of the Path property.
The pattern includes:
-
(((00|\+)(420|43))|0): finds 00420, 0043, +420, +43, or 0
-
\s?: possible space
-
\d+: one or more digits
-
/?: possible forward slash
-
(\s?\d)+: string of digits with possible whitespace in between
The possible search results include +43664 1234567, 0699 1234 5678 9, or 00420669/1 23 456 7.
-
-
If the telephone number matches, the insert outbound step property writes the value valid phone number to the payload.
schema: SimV1
- name: Service08
steps:
- direction: In
trigger:
- type: Path
value: '{REGEX["(((00|\+)(420|43))|0)\s?\d+/?(\s?\d)+"]}'
- direction: Out
insert:
- value: 'valid phone number'
The expression {REGEX["^\d{1,2}[ /.-]\d{1,2}[ /.-](\d{4}|\d{2})$"]} searches for dates in various formats.
The pattern includes:
-
^: beginning of the line
-
\d{1,2}: day (one or two digits long)
-
[ /.-]: separators (space, forward slash, dot, or hyphen)
-
\d{1,2}: month (one or two digits)
-
[ /.-]: separators (space, forward slash, dot, or hyphen)
-
(\d{4}|\d{2}): year (two or four digits)
-
$: end of line
Possible search results are 9/3, 12.12.87, 1-1-1999, 11.1986, 04/23/2007, or 01.03.2000, 4.8.
Use the expression {REGEX["^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$"]} to search for a date and time in the ISO 8601 format of Universal Time Coordinated (UTC).
The pattern includes:
-
^: beginning of line
-
\d{4}: year (four digits)
-
-: separator (hyphen)
-
\d{2}: month (two digits)
-
-: separator (hyphen)
-
\d{2}: day (two digits)
-
T: delimiter between date and time
-
\d{2}: exactly two digits
-
:: separator (colon)
-
\d{2}: hour (two digits)
-
:: separator (colon)
-
\d{2}: second (two digits)
-
Z: time zone designator (UTC)
-
$: end of line
Possible search results are 2013-10-03T12:00:00Z, 1776-07-04T13:37:11Z, or 1993-01-01T00:00:00Z.