[Home]

Summary:ASTERISK-20715: REGEX function ignores shorthand character starting with backslash
Reporter:Cam (cam)Labels:
Date Opened:2012-11-21 12:14:23.000-0600Date Closed:2012-11-21 15:19:50.000-0600
Priority:MajorRegression?
Status:Closed/CompleteComponents:
Versions:1.8.18.0 Frequency of
Occurrence
Related
Issues:
Environment:Centos Linux 5.8Attachments:
Description:The following code fragment SHOULD evaluate to 1 (in variable isittf) but it does not:

{noformat}
exten => s,n,Set(testnum=18005551212)
exten => s,n,Set(tftest=^1?8(00|22|33|44|55|66|77|88)[2-9]\d{6}$)
exten => s,n,Set(isittf=${REGEX("${tftest}" ${testnum})})
exten => s,n,NoOp(Value of isittf is ${isittf})
{noformat}

However if the second line above is changed to:

{noformat}
exten => s,n,Set(tftest=^1?8(00|22|33|44|55|66|77|88)[2-9][0-9]{6}$)
{noformat}

Then it works. It appears that {noformat}\d{noformat} or probably any shorthand character starting with a backslash in the REGEX string is ignored or incorrectly parsed, even if first placed in a variable as I have done here.  I did try using a double backslash {noformat}\\d{noformat} but that did not work either.

If there is a fix for this I would appreciate it if it could be backported to the 1.8 branch.
Comments:By: Matt Jordan (mjordan) 2012-11-21 15:19:41.900-0600

REGCOMP is built on the GNU extended regular expressions library (see {{regex.h}}).  That library does not support the shorthand characters (see [this comparison of regular expression libraries|http://www.regular-expressions.info/refflavors.html]).

As such, this is not a bug, but a limitation of the library that provides the regular expression functionality.