Re-write outbound number

Status
Not open for further replies.

tdcockers

Member
Mar 9, 2018
44
0
6
45
When a mobile phone calls in to our system, it shows up as 61xxxxxxxxx, with 61 being our (AU) country code. If a user then tries to call the number from their call logs, we get an error from our SIP trunk because it thinks we are dialling an 11-digit international number.

Is it possible to re-write destination_number in the dialplan (or elsewhere) to replace the 61 with a 0 before sending the call to the trunk provider?
 
OK, so I've got it to work by creating a new dial plan with the condition ^\+?61?(\d{9})$ for destination number, but don't understand why this works. I assumed that 'condition' would just be a trigger, but it seems that only the 9 digits are now being sent to the trunk. I know basically nothing about regex but need to start... can someone clarify why this worked?
 
Awesome, thanks... will use that more specific regex for the condition for sure. Where does the 0$1 variable get its value from?
 
Where does the 0$1 variable get its value from?

$1, $2 etc are inline captured group from the regex match.
If you have a regex ^(ab)(cd)$ then
$0 = abcd The whole matched string
$1 = ab matched string inside first parenthesis/group
$2 = cd matched string inside second parenthesis/group

You can also do named capture groups which is useful in programming more complex scenarios.
https://www.regular-expressions.info/refext.html
 
Got it, thanks :) Cheers for talking the time to explain, I'll be off to do some more study now I think.
 
Status
Not open for further replies.