SOLVED Outbond not working with regex: INVALID_NUMBER_FORMAT

Status
Not open for further replies.

Tobias.F

New Member
Aug 2, 2020
20
2
3
Hello,

after having fixed my type in the inbound routes (link), now I got stuck at the outbound routes.

If I simple use the following as dialplan expression, all is working fine:
Code:
^$
But if I use this one, it is not working:
Code:
^(|49|\+49|0049|0)[1-9](\d*)$

What I want to achieve is to catch local German numbers in all possible variations. Maybe this regex is not a masterpiece of art but it should be correct and all my tests on online regex tester are OK. Dialing the same phone number as before, I get an error

c7df482e-5673-4ee0-b63c-f9a65a3f310a 2024-03-29 16:06:41.505901 95.07% [INFO] mod_dptools.c:3635 Originate Failed. Cause: INVALID_NUMBER_FORMAT

Any idea what is wrong with my regex?
 
Last edited:

Adrian Fretwell

Well-Known Member
Aug 13, 2017
1,498
413
83
You have two capturing groups there so the contents of \d* will end up in $2.

The first alternative of your first capturing group will always match nothing (a zero length string), that may be why you are seeing the INVALID_NUMBER_FORMAT error.

You can make your first group non-capturing with ?: i.e. (?:|49|0049)
 
  • Like
Reactions: Tobias.F

Tobias.F

New Member
Aug 2, 2020
20
2
3
You have two capturing groups there so the contents of \d* will end up in $2.

Thank you.
I was not aware about the concept of capturing groups. My understanding was that this is just is a filter if the dial plan applies.

I just put the whole regex in brackets to get all in the first capturing group.
Code:
^((|49|\+49|0049|0)[1-9]\d*)$
 
Last edited:
Status
Not open for further replies.