[Home]

Summary:ASTERISK-00228: Regular expressions matching against the * character seem to fail
Reporter:John Todd (jtodd)Labels:
Date Opened:2003-09-06 02:37:46Date Closed:2004-09-25 02:46:18
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:I am having Yet Another Regular Expression problem, but this one might not be my fault, or at least it might not be obviously my fault.  :-)

exten => 2212,1,SetVar(FOO=123456**)
exten => 2212,2,SetVar(BAR=$[${FOO:-1:1} = *])

This script continues with a value of 0 in BAR.

Similarly, none of the following changes made a difference in that result, which is expected since the * is not listed in README.variables as a character that must be escaped:

exten => 2212,2,SetVar(BAR=$[${FOO:-1:1} = "*"])
exten => 2212,2,SetVar(BAR=$[${FOO:-1:1} = "\*"])
exten => 2212,2,SetVar(BAR=$[${FOO:-1:1} = \*])

I have also tried setting the variable ${BAZ}=*  and then using that in my comparison, with the same unexpected results.

Oddly enough, this almost-identical example below has different, but "normal", results: BAR=1

exten => 2212,1,SetVar(FOO=123456##)
exten => 2212,2,SetVar(BAR=$[${FOO:-1:1} = #])


What gives?  Am I colliding with a problem that is the result of the "*" character being used in expr evaluations and somehow not being handled correctly, or am I simply not implementing the syntax correctly?
Comments:By: John Todd (jtodd) 2003-09-06 13:30:52

Looks like a bug in =, then.  I'll add this text to the bugnote.  The ${FOO:-1:1} seems to always return theh "right" reply (the last character of the string) but the = operator for some reason doesn't like "*" (ironic, since it's an Asterisk.  :-)

exten => 2213,1,SetVar(FOO=123**)        
exten => 2213,2,SetVar(CHECK=${FOO:-1:1})

   -- Executing SetVar("SIP/2203-2a83", "FOO=123**") in new stack
   -- Executing SetVar("SIP/2203-2a83", "CHECK=*") in new stack

JT

> What does this step show on the CLI ?
> exten => 1,1,SetVar(FOO=123**)
> exten => 1,2,SetVar(CHECK=${FOO:-1:1})
>
> ? If you're going to see CHECK=* then there is a bug in = operator ...
>
> Martin

By: John Todd (jtodd) 2003-10-16 04:15:14

I'll hand this one to Martin, since he chimed in earlier and it's been sitting around since...  :-)

By: Mark Spencer (markster) 2003-10-22 21:46:49

Asterisk doesn't like a comparison with * by itself since * is also a multiply symbol.  Try doing this:


exten => 2212,1,SetVar(FOO=123456**)
exten => 2212,2,SetVar(BAR=1$[${FOO:-1:1} = 1*])

and it should work.  please confirm.

By: x martinp (martinp) 2003-11-03 15:49:58.000-0600

exten => 2212,1,SetVar(FOO=123456**)
exten => 2212,2,SetVar(BAR=$[1${FOO:-1:1} = 1*])

This works, should be enough ... for now

By: x martinp (martinp) 2003-11-03 15:50:54.000-0600

Use the sytax proposed by Mark