Recursive
2015-Nov-09 14:06 UTC
[asterisk-users] How to encode plus sign in REGEX function in dialplan?
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. 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. The reason why I even have thought of REGEX not behaving like expected: The other day I have read some tutorials / articles about variables and strings in Asterisk dialplans. One of them (I really can't remember which one) claimed that there were problems with special characters in strings, for example with the dollar character ($). They recommended to do something like the following *if* such problems would show: Set(DOLLAR=$) ... head_of_string${DOLLAR}tail_of_string They also claimed that there were other problematic characters which could be handled the same way. That seemed logic to me and lead me into thinking that the pattern string in the REGEX call could be affected by this; hence my initial post. I am apologizing that I haven't found the bug in my dialplan at an earlier time. Best regards, Recursive
Olivier
2015-Nov-09 14:54 UTC
[asterisk-users] How to encode plus sign in REGEX function in dialplan?
2015-11-09 15:06 GMT+01:00 Recursive <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. 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)> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20151109/07425a66/attachment.html>
Recursive
2015-Nov-10 07:53 UTC
[asterisk-users] How to encode plus sign in REGEX function in dialplan?
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