[asterisk-users] a little regex help needed

Jared Smith jsmith at digium.com
Mon Oct 20 13:20:17 CDT 2008


On Mon, 2008-10-20 at 14:10 -0400, sean darcy wrote:
> exten =>s,n,Set(CALLERID(name)=${IF($[0${CALLERID(num)} = 
> 0${REGEX("21245711*")} ] ? "Office":${CALLERID(name)} )})

[snip]

> What I'd expect is a callerid(num) of 2124571123 to generate an if test 
> of  [02124571123 == 021245711*] or TRUE.
> 
> But I've messed up the regex statement somehow.

In regular expressions, the * means zero or more of the preceding
character, so the way you have that written means "021245711 and zero or
more 1s".  What you want instead is "021245711.*", which means
"021245711 followed by at least on other character".

Hopefully that sets you on the right path.  Don't forget that Asterisk
has two regex operators that can be used in expressions as well...
they're the ':' and '~' operators.


-- 
Jared Smith
Training Manager
Digium, Inc.




More information about the asterisk-users mailing list