Numbers translations

Yeti has flexible configuration of numbers modifications - it allows to change source and destination numbers on different call processing stages:

  1. Before routing, immediately after call authorization at Customers Auth.

  2. Before routing, during Numberlist processing.

  3. After routing in Dialpeer.

  4. After routing at termination Gateway.

In most cases numbers translations implemented using POSIX Regular Expressions. This section describes general principles and examples of using POSIX Regular Expressions in Yeti.

Yeti uses Postgresql REGEXP_REPLACE(phonenumber, rewrite_rule, rewrite_result) function with following arguments:

phonenumber

It is a phone number (source or destination) that replacement should be taken place.

rewrite_rule

It is a POSIX regular expression for matching substrings that should be replaced.

rewrite_result

It is a string that to replace the substrings which match the rewrite_rule.

The REGEXP_REPLACE() function returns a new phonenumber with the elements, which match a regular expression pattern, replaced by a new substring.

Examples

How to add prefix 888 to number

rewrite_rule = ^(.*)$
rewrite_result = 888\1

where ^ - matches at the beginning of the phonenumber, $ - matches at the end of the phonenumber, (.*) - regular expression matches a sequence of 0 or more characters, 888 - prefix to add, \1 - first marked subexpression matched (in our case - it is phone number (source or destination) that replacement should be taken place). Some examples of adding digits to the beginning of the phonenumber with using different arguments are provided below:

  1. original phone number = 7335255 ; rewrite_rule = ^(.*)$ ; rewrite_result = 0\1 ; resulting phone number = 07335255

  2. original phone number = 2296132 ; rewrite_rule = ^(.*)$ ; rewrite_result = 066\1 ; resulting phone number = 0662296132

  3. original phone number = 7050460 ; rewrite_rule = ^(.*)$ ; rewrite_result = 38048\1 ; resulting phone number = 380487050460

How to remove prefix 999# from number

rewrite_rule = ^999#(.*)$
rewrite_result = \1

How to add suffix 1235 to number

rewrite_rule = ^(.*)$
rewrite_result = \11235

How to replace prefix 123# with prefix 321#

rewrite_rule = ^123#(.*)$
rewrite_result = 321#\1

How to add 8 random digits to the end of phonenumber

to generate random digits r(N) function may be used:

rewrite_rule = ^(.*)$
rewrite_result = \1r(8)

How to replace 4 last digits to random values

rewrite_rule = ^(.*)(\d{4})$
rewrite_result = \1r(4)