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

Recursive lists at binarus.de
Tue Nov 10 01:53:36 CST 2015


On 09.11.2015 15:54, Olivier wrote:
> 
> 
> 2015-11-09 15:06 GMT+01:00 Recursive <lists at binarus.de <mailto:lists at binarus.de>>:
> 
>     On 06.11.2015 14:06, Rusty Newton wrote:
>     >
>     > It should be able to handle typical regular expression. I don't see
>     > anything wrong with what you are doing. Please file a bug at
>     > issues.asterisk.org/jira <http://issues.asterisk.org/jira>.  Do include a debug log on the issue
>     > captured when Asterisk attempts to execute these extensions.
>     >
>     > https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information
>     >
> 
>     Thanks to your above hint, I have reviewed my dialplan again and have found a bug in it. After correcting my dialplan, it turned out that you are right (of course): REGEX now behaves like expected.
> 
> 
> How would you then recommand  to deal with  + sign in REGEX ?
> Something like 1) ?
> 1) same => n(A1), GotoIf($[${REGEX("^\\+49.*" ${EXTEN})}]?:A2)
> 

I was just about writing an additional comment to this thread when I saw your message.

Indeed, after I had corrected the bug in my dialplan, it turned out that at least the backslash obviously must be encoded by doubling it. I don't know if this is a common rule for *all* strings which are used in a dialplan or if it is a rule which is specific to the REGEX function.

I tend to assume the former because otherwise Rusty's statement (REGEX handles usual regular expressions) would be wrong.

In every case, the variant 1) you have cited above is working for me.

Regards,

Recursive




More information about the asterisk-users mailing list