Stripping unwanted leading digits in both directions

In this example, unwanted leading digits are stripped from numbers in both directions. You may occasionally need to strip digits from a number; for example, the trunk prefix, area code, and country code. Only the last seven digits are passed from PSTN to SIP or from SIP to PSTN.

Note: For simplicity, this example assumes that all inbound calls using TEL URIs are PSTN calls and that SIP calls never use TEL URIs. In cases where the gateway needs to match inbound PSTN calls and inbound SIP calls that use TEL URIs to different routes, you must define separate routing profiles. See the Inbound protocol parameter in General routing profile parameters.

ID

Profile

Incoming Called party

Incoming Calling party

Outgoing Called party

Outgoing Calling party

1

Default

tel:\d*(\d{7})$

tel:\d*(\d{7})$

sip:$1@hostname.com

sip:$1@gateway

2

Default

sip:\d*(\d{7})@.*

sip:\d*(\d{7})@.*

tel:$1

tel:$1

The following rules are used in this example:

Rule

Description

1

Matches any PSTN calling/called numbers containing at least seven digits, captures only the last seven digits to insert into SIP From/To headers.

2

Matches From/To URI containing at least seven digits before @, captures only the last seven digits to insert into PSTN calling/called numbers.

Sample Input/Output: Incoming PSTN call (rule 1 match)

Calling: tel:18479258900 => sip:9258900@gateway
Called: tel:5082711000 => sip:2711000@hostname.com

Sample Input/Output: Incoming SIP call (rule 2 match)

From: sip:18479258900@10.3.6.9 => tel:9258900
To: sip:5082711000@10.3.6.1 => tel:2711000