Dialplan & Trunk Regex
Dialplan Regex examples
For star codes to work in the dial plan, you must configure Star codes that are handled in dial plan. For e.g. set to *67*
to allow calls like *6723232323
, *67232323232323
, etc.
Pattern | Replacement | Example Input | Example Output | Description |
---|---|---|---|---|
\*67([0-9]{6})(@.*) | \*67\1\2 | *67112233 | *67112233 | Caller ID blocking: Preserves *67 prefix with 6-digit number |
\#5(011[0-9]{6,20})(@.*) | \1\2 | #50113344556677 | 0113344556677 | International dialing shortcut: Removes #5 prefix, keeps international number |
^0(9[0-9]{7})(@.*) | +64\1\2 | 093445565 | +6493445565 | New Zealand national to international: Converts 0 prefix to +64 country code |
Pattern Explanation
\*67([0-9]{6})(@.*)
: Matches "*67" followed by exactly 6 digits, captures the digits and any following context\#5(011[0-9]{6,20})(@.*)
: Matches "#5011" followed by 6-20 additional digits, captures the international number and context^0(9[0-9]{7})(@.*)
: Matches line starting with "0" followed by "9" and exactly 7 more digits, captures the national number and context
Replacement Explanation
\*67\1\2
: Keeps the "*67" prefix, followed by captured digits (\1) and context (\2)\1\2
: Returns only the captured international number (\1) and context (\2), removing the "#5" shortcut+64\1\2
: Replaces the "0" with "+64" country code, followed by the captured number (\1) and context (\2)
Trunk Regex Examples
You can use a list of regex expressions to route incoming calls. Below is an example with two separate conditions using space as the delimiter:
!^1?([0-9]{9})$!61\1!t!123! !^0?([0-9]{9})$!61\1!t!123!
Regex Pattern Breakdown
Pattern | Received Number | Final Number Searched | Description |
---|---|---|---|
!^1?([0-9]{9})$!61\1!t!123! | 1300300300 | 611300300300 | Matches optional "1" prefix + 9 digits, replaces with "61" + captured digits |
!^0?([0-9]{9})$!61\1!t!123! | 0233445566 | 61233445566 | Matches optional "0" prefix + 9 digits, replaces with "61" + captured digits |
How It Works
First regex pattern: When a number like 1300300300
is sent to the PBX (or when formatting is enabled for specific Caller ID display that also formats the destination number), the first regex pattern will replace it with 611300300300
.
Second regex pattern: When a number like 0233445566
is sent to the PBX (or when formatting is enabled for specific Caller ID display that also formats the destination number), the second regex pattern will replace it with 61233445566
.