[SR-Users] DIALPLAN Module: doubts about regular expression usage

Stefano Bertuola stefano.bertuola at gmail.com
Tue Oct 9 17:20:34 CEST 2018


Hi Experts.

I did some tests with DIALPLAN module and I have some doubts about how to
define the regular expressions in the database.

For example, using the start character '^' (beginning of the string), it
looks not working:

kamcmd> dialplan.dump 1
{
        DPID: 1
        ENTRIES: {
                ENTRY: {
                        PRIO: 1
                        MATCHOP: 2
                        MATCHEXP: ^(\+39)(.*)$
                        MATCHLEN: 0
                        SUBSTEXP: ^(\+39)(.*)$
                        REPLEXP: \2
                        ATTRS: 1
                }
        }
}
kamcmd> dialplan.translate 1 "+39123456"
error: 500 - No translation


Removing it, it works... but not as desired:

kamcmd> dialplan.dump 1
{
        DPID: 1
        ENTRIES: {
                ENTRY: {
                        PRIO: 1
                        MATCHOP: 1
                        MATCHEXP: (\+39)(.*)$
                        MATCHLEN: 0
                        SUBSTEXP: (\+39)(.*)$
                        REPLEXP: \2
                        ATTRS: 1
                }
        }
}
kamcmd> dialplan.translate 1 "+39123456"
{
        Output: 123456"
        Attributes: 1
}
kamcmd> dialplan.translate 1 "xxxxxxx+39123456"
{
        Output: 123456"
        Attributes: 1
}


Can someone help me understand how the regular expression should be used in
DIALPLAN, please?

Br. Stefano
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20181009/13982f9c/attachment.html>


More information about the sr-users mailing list