Introduction


The translation rule replaces a sub string of the input number if the number matches the match pattern. The regex engine is used to check for a match based on the match pattern. In other words, this translation rule is to convert the prefix of number as your requirement.


Translation rule is applicable to both types of trunks: Inbound and Outbound.

  • Number of translation rules can be created: unlimited.

  • Number of translation rules can be applied to one trunk: maximum 5 rules.

.

Parameters


  • Name: name of translation rule

  • Pattern: the pattern of number which will be applied to translation rule

  • Replacement: the replacement for the number if pattern is matched

Pattern and Replacement must follow Perl Compatible Regular Expressions (PCRE)  syntax.

.

Syntax Description


Below table shows most formalisms provide the following operations to construct regular expressions.


Char
Description
Example
Match
Mismatch
^
The beginning of a line.
^65
656111xxx
8656111xxxx
$
The end of a line.

123$

xxxxx123

xxxxx1234

\
Escape the special character.
\\
\

.
Match any chars except new line
1.234
10234
1234
?
Zero or one quantifier
1?234
1234, 10234
100234
+
One or more quantifier
1+234
10234, 100234
1234
*

Zero or more quantifier

1*112

1112, 13112, 133112
111
|
Alternation
1|2
1, 2
3, 4, 5
[]

Match a single chars in a class

12[345]67
12367, 12467

12667, 12767, 12867

[^]
Not match a single chars in a class
12[^345]6
1266, 1216
1236, 1246, 1256
[n-m]
Range of match chars in a class
123[1-6]

1232, 1231, 1236

1230, 1237
{n}
Number of occurrences for the previous digit

Exactly n digits 
125{2}4
12554
1254, 125554
{n,m}
Number of occurrences for the previous digit

From n to m digits
125{2,3}4
12554, 125554

1254, 1255554

()
sub-pattern or reference group



%{n}
Back-reference to group in pattern




.

Create new Translation Rule

  1. Go to Setting > Translation > Click New profile

  2. Give new rule a name > Input Pattern & Replacement > Create


    .

  3. Finish

Examples


Add country code 65 for Singapore local number

  • Pattern: ^([3689][0-9]{7})$

  • Replacement: +65%{1}

  • Translations:  

    • 66123456 +6566123456

    • 91234567 +6591234567

    • 12345678  12345678 (no change)

.

Remove country code 65 for Singapore international number

  • Pattern: ^65([3689][0-9]{7})$

  • Replacement: %{1}

  • Translations:  

    • 6566123456  66123456

    • 6591234567 91234567

    • 6512345678 6512345678 (no change)

    • 8412345678 8412345678 (no change)

.

.

Test the Translation Rule


You can use this link for regex testing.