Catching different prefixes, remove part of them and search in database

Suppose there is possibility to receive calls with prefix “123” like this “+123 5677”, “123 5677”, “05677” and “5677”. I have saved numbers in the database in clean view eg. without prefixes “5677”.

I’m trying to make my dialplan when the number is come no matter what prefix is having - to remove it and search for the clean number.

So far I have this:

exten => _[a-z].,1,Set(SAFE_EXTEN=${FILTER(0-9,${EXTEN})})

So, this will catch if there are letters as a prefix: “abc5677” and will strip them to “5677”. What about “+123”, “123” and “0”. Any help is appreciated!

exten => _[+a-z0-9].,1,

–Satish Barot

Normally you would match the specific prefix and GoTo the extension without the prefix. Both matching prefixes and stripping them are in the sample configuration file.

Thanks. Turn out the problem is how to catch it? On which step? I mean some extension calling to voicemail number.

This extension is saved as “1001” but when call to voicemail number “199” it’s presented as “01001”. So, when I must remove this leading “0”, before hit voicemail number or how?

We’d need to know a lot more about your existing configuration and, I suspect, that would go beyond the reasonable expectations of support from a peer support forum.

Currently, it’s simple configuration. I have sip users saved in table sipfriends. The goal is on an incoming call to check if prefix exists. If exists - remove it and look into the table for that number.