[asterisk-users] dialplan pattern help

Leif Madsen leif.madsen at asteriskdocs.org
Sat Jul 23 13:18:03 CDT 2011


On 11-07-23 10:30 AM, Armand Fumal wrote:
> Hi all,
> 
> I need help for make a pattern for a special case that i can't find the solution.
> 
> In my case I want to match these in one pattern:
> 
> This is the same ext that can come in 4 cases
> 
> exten => _42704701,1,Macro(dialfax,${EXTEN:-8})		; case with 42704701
> exten => _X42704701,1,Macro(dialfax,${EXTEN:-8})		; case with 042704701
> exten => _XXXX42704701,1,Macro(dialfax,${EXTEN:-8})	; case with +3242704701
> exten => _XXX42704701,1,Macro(dialfax,${EXTEN:-8})		; case with 3242704701
> 
> I have try _.42704701 but the parser stop to check after the point "."    :-(
> 
> So did you have any suggestion ?

Ya you can't match anything after the '.' in pattern matching.

I'm not sure the pattern matcher is really capable of doing what you want here.
The only way to do it really is to match less restrictively and perform a check
using dialplan applications/functions, and then if nothing is found, to fall
through.

Perhaps something like:


exten => _XXXXXXXXXXX,1,NoOp()
   same => n,ExecIf($["${EXTEN:-8}" = "42704701"]?Macro(dialfax,${EXTEN:-8}))
   same => n,Verbose(2,Did not match -- falling through)
   same => n,Playback(invalid)
   same => n,Hangup()

I'm pretty sure that's the only way you can do it in a single line (the ExecIf()
application).

Leif Madsen.



More information about the asterisk-users mailing list