Project

General

Profile

Regex patterns

In various modules of a system you can use string replacement by regular expressions.
The examples of such modules are:

This functionality is used to replace the original string by certain rule.
Most often this is used to manipulate with inbound and outbound numbers, for example:
  • cutting off technical prefix
  • adding technical prefix

Rule formats.

Replacement rules can be defined using various syntaxes:

How number replacement is done.

Smartswitch takes original sring and begins iteration over configured rules according to rule priorities.
Rules with less priority value are handled first.
In web-interface rules by default are sorted according to priority.
Therefore, iterating replacement rules will be done from top to bottom.

For each rule system tries to find a match of original string to a regular expression, configured inside rule.
To find a match, specified format is used and a value of regular expression.

After match has been found, a replacement is done according to configured rule application options and a value inside replace field.
After replacement has been done, the original string is replaced with new one.
In case if option continue is not checked - search and replace stops.
In case if set - system moves to a next rule from the list according to priorities.

In case if match according to regular expression hasn't been found for current rule - system moves to a next rule from the list according to priorities.

Rule application options for replace patterns.

  • only first.
    This option controls, whether or not only first occurrence should be replaced.
    For example, rule defined as 777 -> 888, original string is 17772777.
    Then this option is disabled, string is replaced to 18882888.
    When this option is enabled, string is replaced to 18882777.
  • don't copy.
    This option controls, whether a part of original string which didn't match should be presend is resulting string or not.
    For example, the rule defined as 777 -> 888, original string is 17772434.
    When this option is disabled, string is replaced to 18882434.
    When this option is enabled, string is replaced to 888.
  • continue.
    This option controls, whether or not system will move to next rule in a list after the current rule is applied.
    For example, the rule defined as 777 -> 888, original number is 17772434.
    When this option is disabled, string will be replaced to 18882434 and replacement will stop.
    When this option is enabled, string will be replaced to 18882434 and replacement will continue according to a next configured rule in a list.

Русский перевод

Also available in: PDF HTML TXT