Regular expression rules, Routing rules – AASTRA BluStar 8000i BAS-Mode Administrator Guides EN User Manual
Page 100
Routing Rules
7-6
41-001391-00 Rev 03 – 04.2012
Regular Expression Rules
Regular expression rules perform pattern matching on SIP Request-URIs and can then create a new Request-URI based
on parts of the original Request-URI. This can be used for example to rewrite calls to telephone numbers to include pre-
fixes for outside lines, area code or calling cards as appropriate. A brief summary of regular expression syntax is given
below.
•
Characters not listed below as special characters match themselves.
•
Special characters:
. Matches any character
[...] Character class: matches range(s) and/or list(s) of characters (e.g. [0-9a-zA-Z] matches a digit or letter)
[^...] Inverted class: matches all except a member of a class, (e.g., [^a-zA-Z] matches anything except a letter)
? Preceding item is optional (may occur zero times or once)
+ One or more of preceding item
* Zero or more of preceding item
{m,n} Between m and n occurrences (inclusive) of preceding item
^ Match the beginning of the URL
$ Match the end of the URL
() Used for grouping and for back-referencing
\ Quote the next special character, e.g. when trying to match a character such as a + sign.
•
Back-references in replacement URL:
$1 refers to text matched by first set of () , $2 refers to second () , etc.
Examples
^sip:([0-9]+)@
Matches start of URL, “sip:”, one or more digits, and an “ @ ” sign. The administrator could ask the system to replace
this with e.g., “ sip:[email protected] ”- $1 will be what was matched by first set of () , i.e., the part between “ sip: ”and “ @ ”.
This would send all URLs containing digits to the SIP device at IP address 1.2.3.4.
^sip:([2-8][0-9]{9,9})@([a-zA-Z0-9\.]+)
Matches the “sip:” at the start of the URL, a ten digit number that starts with a digit between “2” and “8”, and an “@”
sign.
The replacement text “sip:91$1@$2;user=phone” will prepend the original number with a 9 (for an outside line),
and a “1” (to make a long distance call). The URL is converted into a telephony URL.
^(sip:)?\+([0-9]+)@
Matches start of URL, optionally “sip:”, a literal “+” sign (“+” is a special character so we need a “\” before it), one or
more digits, “@”.
The administrator could specify as replacement text e.g., “sip:[email protected]:5060”. The effect is to replace the “+
country area number” format with the format appropriate for a US company (9 to obtain an outside line; 011 is
international prefix).