[asterisk-users] How to encode plus sign in REGEX function in dialplan?

Recursive lists at binarus.de
Thu Nov 5 00:49:46 CST 2015


Dear all,

I have made a fairly complex dialplan where I am using the REGEX function in many places. This works so far, but I wasn't able to solve the following problem. What I would like to do is the following (please note that this is normal regex syntax and obviously not what the REGEX function expects, but I hope it shows the idea):

  same => n(A1), GotoIf($[${REGEX("^\+49.*" ${EXTEN})}]?:A2)

This line should make Asterisk jump to label A2 if the extension begins with +49. Since the plus sign is a special char in regexes, I have escaped it with \ as usual. But that does not work; the pattern is not matched and the goto is not executed when the extension begins with +49.

What I already have tried:

1) same => n(A1), GotoIf($[${REGEX("^\\+49.*" ${EXTEN})}]?:A2)

2) same => n(A1), GotoIf($[${REGEX("^\\\+49.*" ${EXTEN})}]?:A2)

3) same => n(A1), GotoIf($[${REGEX("^\\\\+49.*" ${EXTEN})}]?:A2)

4) same => n,     Set(REPAT=^+49.*) 
   same => n(A1), GotoIf($[${REGEX(${REPAT} ${EXTEN})}]?:A2)

5) same => n, Set(REPAT="^+49.*")
   same => n(A1), GotoIf($[${REGEX(${REPAT} ${EXTEN})}]?:A2)

6) same => n, Set(REPAT=^+49.*)
   same => n(A1), GotoIf($[${REGEX("${REPAT}" ${EXTEN})}]?:A2)

7) same => n, Set(REPAT="^+49.*")
   same => n(A1), GotoIf($[${REGEX("${REPAT}" ${EXTEN})}]?:A2)

Neither of these worked.

Actually, the REGEX function is not able to handle normal regular expressions. To make things worse, there doesn't seem to be any documentation. Could anybody please point me to documentation or tell me how write that very simple pattern?

Thank you very much,

Recursive

P.S. This happens in Asterisk 13.6.0 - I haven't tested with other versions.



More information about the asterisk-users mailing list