REGEX plus (+) problem

Hi,

I have:
Set(foo="+1234,556677")
Set(bar=+1234)

I want to check if ${bar} contains in ${foo}. Like:
GotoIf($[${REGEX("${bar}" “${foo}”)}]?10:20)

But the problem is the plus (+) sign. If comparing only numbers it works. How to escape that plus sign?

Hi,

Have you read doc/channelvariables.txt this may give you the answer

Yes, I read it.

Hi,

I will put some thought to it in the morning see if I can help.

BW

Hi,

If I am correctly understanding what yoiur are trying to do this sholud work I have tested it on my system.

;Test for Number
exten => 5,1,Answer()
exten => 5,2,Set(foo=$[12345 + 55667])
exten => 5,3,Set(bar=80)
exten => 5,4,GotoIf($["${foo}" =~ ${bar}]?5:7)
exten => 5,5,NoOp(YES)
exten => 5,6,Hangup()
exten => 5,7,NoOp(NO)
exten => 5,8,Hangup()

;Test for string
exten => 6,1,Answer()
exten => 6,2,Set(bla=myfat)
exten => 6,3,Set(lar=cat)
exten => 6,4,Set(foo=${bla}${lar})
exten => 6,5,Set(bar=fat)
exten => 6,6,GotoIf($["${foo}" =~ ${bar}]?7:9)
exten => 6,7,NoOp(YES)
exten => 6,8,Hangup()
exten => 6,9,NoOp(NO)
exten => 6,10,Hangup()

Hi,

Your examples works, but this is not what I want…
I have an external program which send me some numbers to a context. That numbers are comma separated. Example:

$numbers=23456,+4456762,088235,+23567

And I want to check if ${EXTEN} is one of that numbers.

When comparing numbers it’s ok. This plus (+) sign is giving me some problems. I can’t escape it. A temporary solution is to use function CUT (btw with asterisk 1.4 the commas are problems with CUT).

Cheers

Ok I now can see what you are try to do!

Let me have a think about it, see if I can find a way?

Brett

${internal}=222:+12345

exten => _+X.,1,Set(number1=${CUT(internal,:,1)})
exten => _+X.,2,Set(number2=${CUT(internal,:,2)})
exten => _+X.,3,GotoIf($["${EXTEN}" = “${number1}”]?10:20)
exten => _+X.,10,NoOp(EXTEN match number1, i’ll do something…)
exten => _+X.,11,Hangup()
exten => _+X.,20,NoOp(EXTEN DO NOT match number1, i’ll check if match number2)
exten => _+X.,21,GotoIf($["${EXTEN}" = “${number2}”]?30:40)
exten => _+X.,22,NoOp(EXTEN match number2, i’ll do something…)
exten => _+X.,23,Hangup()
exten => _+X.,40,NoOp(EXTEN do not match number1 and number2… i’ll do something…)
exten => _+X.,41,Hangup()

But this is ugly…

Hi,

I must admit I don’t fully understand what you are doing (not 100% on the program sending you the data).

Here is another go not sure if this will help? If not can you tell me more?

;Test
exten => 5,1,Answer()
exten => 5,2,Set(foo=“23456,+4456762,088235,+23567”)
exten => 5,3,Set(bar=088)
exten => 5,4,NoOp(${foo})
exten => 5,5,GotoIf($["${foo}" =~ ${bar}]?6:8)
exten => 5,6,NoOp(YES)
exten => 5,7,Hangup()
exten => 5,8,NoOp(NO)
exten => 5,9,Hangup()

Well… kind of.

exten => 5,5,GotoIf($["${foo}" =~ ${bar}]?6:8)

this goes:
exten => 5,5,GotoIf($[${foo} =~ ${bar}]?6:8)
because:
[Dec 16 09:37:24] WARNING[7493]: ast_expr2.fl:438 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected ‘’, expecting $end; Input:
"“23456,+4456762,088235,+23567"” =~ 233

OK, in your example if I put bar = 088 (or the whole 088235) it is YES. But if put bar = 235 it’s also yes. The number is +23567, not 23567.