Rewriting caller-ids by using REGEX rules
Rewriting caller-ids (source and/or destination phone number) may be useful, when the phone number, retrived from a voip protocol, can be represented in multiple forms (for example, with country telephone code and without).
Format is following
<REGEX-rule> = <Rewrite-To-Expression>
Where:
REGEX-rule
is a Regular Expression to match the phone number. It may contain the groups of characters (delimited by round parentheses), which are copied to the resulting value (see substitute parameters <1>, <2> and <3> in Rewrite-To-Expression).Rewrite-To-Extression
is a phone number with substitute parameters<1>
,<2>
and<3>
(maximum 3 substitute parameters are supported).
Example 1 : Add the prefix "1" to local USA phone numbers
([0-9]{10}) = 1<1>
This will match any phone number, which has exactly 10 digits in length (for example, "2345678901"). Prefix "1" will be added to that phone number. For example, 2345678901 will be overwritten to 12345678901.
The expression "[0-9]{10}
" matches a string, which has exactly 10 characters in length and the string contains only the digits. This expression is written in parentheses, so the value of such match can be used inside "Rewrite-To-Expression" (see "<1>
")
Example 2: Delete the prefix "011" from the phone number
011([0-9]{11,13}) = <1>
This will match any phone number, which starts with "011" and follows 11, 12 or 13 digits after "011". `` For example, 011123456789012 will be overwritten to 123456789012. This rule just removes prefix "011" from the phone number.
The expression "[0-9]{11,13}
" matches a string, which has exactly from 11 to 13 characters in length and the string contains only the digits. This expression is written in parentheses, so the value of such match can be copied to "Rewrite-To-Expression" (see "<1>
")
Example 3: Remove the plus sign from the phone number
\+([0-9]{1,}) = <1>
This will match any phone number, which starts with '+' and follows one or more digits. For example, +1234 will be overwritten to 1234. There is a backslash before the plus sign. This is a requirement because plus sign has special meaning in REGEX. Backslash is used to disable such special meaning and to use the plus sign just as a regular character.
The expression "[0-9]{1,}" matches a string, which has at least one digit character (maximum length is not limited. It can be 1, 2 or any other number of digits).