Re-write outbound number

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?


Active Member
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.