Knowledgebase |
Knowledgebase > Unified Communications > SmartNode > SmartMedia > SN10K |
|
||||||||||||||||||||||||||||||||||||
How to Use RegEx in Remapped Called and Calling Number Mask | |||||||||||||||||||||||||||||||||||||
Article Id #: 428 | |||||||||||||||||||||||||||||||||||||
Regular Expressions: A regular expression is a sequence of characters that forms a search and replace pattern. This is useful to modify the called or calling number digit strings. The version used in the SmartMedia SN10K units is based on PERL regular expression.
The Rule: The remapped called number mask or remapped calling number mask must have 2 regular expressions, and it must be in the form of '/regexWithCapturingGroup/replaceString/'. In the first regular expression, you specify capturing groups using parentheses (...) while in the second regular expression, you specify how to remap the number by referencing the capturing group using \1, \2, etc. Please refer to the Quick Reference Table below.
Example 1: If you need to match a called number starts with the digits 450 and then 7 other digits, please put this in the called number mask: /^450[0-9]{7}$/ ^ means the matching is done from the beginning of the number. $ means the matching is done to the end of then number. 450 is the exact prefix to match. [0-9]{7} means there should be 7 occurrences of the digits 0 to 9. [1-9]{7} would mean 7 digits, excluding 0.
Example 2: In this example, we have to match a called number starts with optional 1, then digits 450 and then 7 other digits. /^1?450[0-9]{7}$/ ? means the preceding pattern, i.e. the digit '1', is optional. Example 3: In this example, we have to match a called number with 4 possible prefixes followed by 7 other digits. /^(800|888|877|866)[0-9]{7}/ In this example, we have 2 independent regular expressions. The first one match prefix '800' with 7 digits, second match prefix '88' with 8 digits. /^800[0-9]{7}$|^88[0-9]{8}$/ The | (pipe character) means "or"
Example 4: In this example, we have to match a called number with a prefix followed by 6 to 11 digits. /^880([0-9]{6,11})$/
Example 5: In this example, we want to match any digit string that doesn't start with 080. /^(?!080)([0-9]*)$/ The ?! is the not operator (everything except this)
Example 6: In the remapped called number mask, the following is specified: /^(1?)450([0-9]{7})$/\1514\2/ The first regular expression is '^(1?)450([0-9]{7})$'. There are 2 capturing groups. The first one is '(1?)', the optional digit '1'. The second one is '([0-9]{7})', the 7 digits following '450'. The second regular expression is '\1514\2' which specifies how the remapped number is composed. In this example, let us suppose that the incoming call has the called number as '15141234567'. The digit '1' in the beginning matches the first capturing group '(1?)' and the digits '1234567' match the second capturing group '([0-9]{7})'. Therefore, the remapped called number would be '1' followed by '514' followed by '1234567', that is '15141234567'.
Example 7: This is a simpler example in which the remapped called number mask would remove the prefix '852' while keeping the 8 digits following the prefix. /^852([0-9]{8})$/\1/ First group between parenthesis are the 8 digits after the 852. The output number will be the 8 digits after 852 (represented by the first group "\1" used in the seconds section of the regex)
Quick Reference Table:
Here are some examples:
Add 2720 prefix:
/^(\d+)$/2720\1/
or
/^([0-9]*)$/2720\1/
Strip first 4 digits:
/^([0-9]{4})([0-9]*)$/\2/
Strip # and 7 first digits:
/^([#])([0-9]{7})([0-9]*)$/\3/
|
|||||||||||||||||||||||||||||||||||||
User Rating | |||||||||||||||||||||||||||||||||||||
This answer was helpful | This answer was not helpful | (8763 vote(s)) | |||||||||||||||||||||||||||||||||||
User Comments ( Add a Comment ) |
Company > Contact Us > About Patton > Jobs > Capabilities > Quality & Responsibility > Legal News & Events > Press Room/Releases > Training & Events > Library/Downloads |
| Sitemap | Legal | Privacy Policy | Disclaimer |