[Asterisk-Users] extensions and regular expressions ( probably an easy question )

Daniel Wright dw at wonderwave.net
Sat Dec 10 17:13:22 MST 2005


Sorry I read that wrong.

You could use something like this or just put two lines for each extension

exten => s,1,GotoIf($[$[${EXTEN:0:4} = 1866]?2:3)
exten => s,n,GoTo(wherever1)
exten => s,n,GoToif($[${EXTEN:0:3} = 866]?4:5)
exten => s,n GoTo(Wherever2)
exten => s,n,What-ever-could-come-next

You can also change the jump 2:3/4:5 to the contexts you want to go to. I am fairly new to the dialplan so not sure if this will work exactly like you 
need, but this should give you an idea of where to go from here.

Hope this helps

Dan



Sean Kennedy wrote:
> Hi Dan,
>
> Thanks for the info, but what I'm after is the ability to match a 
> digit/character 0 or 1 times at the beginning of the string.  If I'm 
> reading your example right, it'll match anything starting with 866, 
> which doesn't work for me.  I am trying to match:
>
> 18661234567 and 8661234567
>
> Sean
>
> ps:  The pdf doesn't have a good explaination of this either, although 
> it occurs to me that this might not be possible with * if I'm having 
> such a hard time finding it.
> Daniel Wright wrote:
>
>> Sean Kennedy wrote:
>>
>>> Hi all,
>>>
>>> I'm having a hard time finding information related to the regular 
>>> expressions that can be used in a dialplan, specifically as an 
>>> extension.  For example, I have an 800 number which I'd like to jump 
>>> directly to if my users dial it, instead of going over my pstn 
>>> termination.  Currently, it looks like this:
>>>
>>> exten => 8661234567,1,Goto(800-in)
>>>
>>> However, I'd like 1866123456 to match as well.  I can't find in the 
>>> wiki or sample configs how to say "match this 0 or 1 times".
>>> Can anybody provide a link that would go over this?  Again, I've 
>>> been digging through the wiki, but I seem to be missing it.
>>>
>>> Thanks
>>>
>>> Sean
>>>
>> You could do it like this:
>>
>> exten => _866.,1,GoTo(800-in)
>>
>> The period means match one or more characters.
>>
>> You can find reference to expressions and how they work  in this pdf 
>> book http://www.nufone.net/downloads/asteriskdocs/AsteriskTFOT.zip
>>
>> Dan
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>




More information about the asterisk-users mailing list