Numbers translations
Yeti has flexible configuration of numbers modifications - it allows to change source and destination numbers on different call processing stages:
Before routing, during Customers Auth processing:
- Customer Auth SRC/DST rewrite rules
- Customer Auth DST Numberlist rewrites
- Customer Auth SRC Numberlist rewrites
Before routing, during Routing Plan Numberlist processing:
- Routing Plan DST Numberlist rewrites
- Routing Plan SRC Numberlist rewrites
After routing:
- Dialpeer SRC Name, SRC Number, DST Number rewrite rules
- Deferred Numberlist rewrites
After routing at termination Gateway:
- DST Termination Numberlist rewrites
- SRC Termination Numberlist rewrites
- Gateway SRC/DST rewrite rules
- Gateway to_rewrite_rule( affects only To-Uri userpart)
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 logic similar to 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 sub-strings that should be replaced.
- rewrite_result
- It is a string that to replace the sub-strings 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 sub-string.
Examples
Some examples of number rewrite configuration are provided below:
| Action | Original Number | rewrite_rule | rewrite_result | Rewrite result |
|---|---|---|---|---|
| Add prefix 0 | 7335255 | ^(.*)$ | 0\1 | 07335255 |
| Add prefix 066 | 2296132 | ^(.*)$ | 066\1 | 0662296132 |
| Add prefix 38048 | 7050460 | ^(.*)$ | 38048\1 | 380487050460 |
| Add prefix + | 380487050460 | ^(.*)$ | +\1 | +380487050460 |
| Remove prefix 999# | 999#380487050460 | ^999#(.*)$ | \1 | 380487050460 |
| Remove prefix + | +380487050460 | ^\+(.*)$ | \1 | 380487050460 |
| Remove first 2 symbols | 380487050460 | ^.{2}(.*)$ | \1 | 0487050460 |
| Remove last 3 symbols | 380487050460 | ^(.*).{3}$ | \1 | 380487050 |
| Add suffix 12345 | 380487050460 | ^(.*)$ | \112345 | 38048705046012345 |
| Replace prefix 123# with 321# | 123#380487050460 | ^123#(.*)$ | 321#\1 | 321#380487050460 |