Pattern matching

Pattern matching

You are here:
Estimated reading time: 2 min.

In Outbound plan and Permission profiles you can use pattern matching.

Patterns can have the following elements:

  • _ pattern prefix, if the pattern starts with ‘_’ then it tries to match. Without it the pattern must be an exact must in order to be true.
    • to match exact number ‘123’ use pattern 123
  • [123] matches digits 1, 2 and 3.
    • to match 34, 37, and 38 use pattern _3[478]
  • [1-5] matches any digit in the range 1 to 5
    • to match any number between 321 and 325 use pattern _32[1-5]
  • [15-7] matches a single character from the range of digits specified.
    • to match 1,2,3,7,8,9 use pattern _[1237-9]
  • X matches any digit from 0-9
    • to match any number between 300 and 399 use pattern _3XX
  • Z matches any digit form 1-9
    • to match any number between 31 and 39 use pattern _3Z
    • to match any number between 301 and 309 user pattern _30Z
    • to match any number between 301 and 399 user pattern _3XZ
  • N matches any digit from 2-9
    • to match any number between 32 and 39 use pattern _3N
    • to match any number between 312 and 399 use pattern _3XN
  • . matches one or more characters, no matter what they are
    • to match all numbers that begin with 001 use pattern _001.
    • Note: pattern _911. match all numbers that begin with 911 but does not match to 911 itself

These are valid patterns:

‘0’ ‘1’ ‘123’ ‘+123’ ‘text’ ‘text.8’ ‘_123’ ‘_0NXX’ ‘_0NX.’ ‘_12[345]6’ ‘_12[3-6].’ ‘_+[0-9]N[1-3]X.’

These are invalid patterns:

‘i’ ‘+’ ‘+1+2’ ‘_text’ ‘_+’ ‘_+N+Z’ ‘_.’ ‘_123M’ ‘_12[34’ ‘_12]34’ ‘_12.34’ ‘_12[#$$]’ ‘_1234..’

Pattern matching order

The order is defined as:

  1. The fixed numbers with no ‘_’ prefix, in alphabetical order.
  2. Patterns (‘_’ prefixed), sorted atom by atom (‘atom’ is a single character, or a single […] range)
    using the following character ordering: ‘0’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’, ‘+’, 0-7 digit ranges, ‘N’, 8 digit ranges, ‘Z’, 9 digit ranges, ‘X’, 10 and more digit ranges, ‘.’

The reason for this is that more than one pattern might match a dialled number, therefor the pattern matching order is based on the quality of the match.
e.g. ‘_X.’, ‘_NXXXXXX’, ‘_XXXXXXX’, ‘_987654X’ can match numbers between 9876540 and 9876549 but ‘_X.’ is the most broad matching so ordering for this example will be:

‘_987654X’, ‘_NXXXXXX’, ‘_XXXXXXX’, ‘_X.’

Was this article helpful?
No