Just can't get simple regular expression to work in asterisk

I ALWAYS get a return code of zero when using regular expressions in the $[ string : expr ]

I’m simply looking for a particular substring 234 within a string 123/234/345/456/ which seems ike a pretty easy task.

exten => 9,n,set(s=123/234/345/456/)
exten => 9,n,set(m=234)
exten => 9,n,set(foo=$[ ${s} : ${m} ])

I tried using =~ instead of : – still get 0.
I tried removing the spaces in line 3 – still get 0.
I tried switching the s and m in the 3rd line (just in case I was reading the docs wrong) – still get 0
but clearly the 234 does exist inside the 123/234/345/456/ so what am I doing wrong here?

BTW when I finally switched to the REGEX function
exten => 9,n,set(foo=${REGEX("${m}" ${s})})
in line 3 it worked. But shouldn’t the first example should work?


specially section named "Substring"
there are examples how : works

Thanks for posting a reply, but that’s not correct.

What I’m trying to use is regular expression inside the $[ ] to see if a substring exists insdie the string already.

The documentation at voip-info.org says:

$[expr1 operator expr2] 

and under Regular expressions it says

 expr1 : regexp

expr1 =~ expr2

so something like $[ 123/456/789 : 456 ] SHOULD work, right?
(or maybe =~ instead)

But in my dialplan example above it does not work, it always evaluates to ZERO!


i’m not english native language user but reading from

i would try something like $[ 456 : 123/456/789 ]