[asterisk-users] a little regex help needed

Steve Murphy murf at digium.com
Mon Oct 20 18:55:19 CDT 2008


On Mon, 2008-10-20 at 16:17 -0700, Edwin Lam wrote:
> sean darcy wrote:
> 
> > OK. So I changed the * to .. , like so:
> > 
> > exten =>s,n,Set(CALLERID(name)=${IF($[0${CALLERID(num)} = 
> > 0${REGEX("21245711..")} ] ? "Office":${CALLERID(name)} )})
> > 
> > which I would expect to mean 021245711 followed by two other characters.
> > 
> > It still matches a blank callerid(num).
> 
> try:
> 
> exten =>s,n,Set(CALLERID(name)=${IF($[ ${REGEX("021245711.." 0${CALLERID(num)})} = 1] ? "Office":${CALLERID(name)})})
> 
> 

and just to round out the discussion, you could also:

(using the =~ and ? :: notation in $[] expressions...)

exten => s,n,Set(CALLERID(name)=$[ 0${CALLERID(num)} =~ 021245711.. ?
"Office" :: ${CALLERID(name)}])

I haven't tried to debug it, but it hopefully will do the job. See
doc/tex/channelvariables or just doc/channelvariables (iirc), depending
on the version of Asterisk...

using the =~ and ? :: notation in $[] expressions...

murf

-- 
Steve Murphy
Software Developer
Digium
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3227 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20081020/7229cc4e/attachment.bin 


More information about the asterisk-users mailing list