[asterisk-users] Pattern matching....

Steve Murphy murf at digium.com
Thu Feb 21 12:21:04 CST 2008


On Thu, 2008-02-21 at 12:44 -0500, Michael Munger wrote:
> Will this work to match any number from the 770,404, or 678 area
> codes? 
> 
>  
> 
> _[404|770|678]NXXXXXX
> 
>  
> 
> If this won’t work, is there a pattern that will do this?
> 
>  

No, it won't work, there's no '|' for alternative matches, and no parens
available for grouping, either. And your usage of char sets is off.
Try something like this:

_404NXXXXXX

_770NXXXXXX

_678NXXXXXX


as three separate extensions.

If you REALLY want to keep that as one extension, then you could:

_NXXNXXXXXX  =>  {
		Set(areacode=${EXTEN:0:3})
		if ('${areacode}' = '404') {
			<things to do here>
		} else if ('${areacode}' = '770') {
			<things to do here>
		} else if ('${areacode}' = '678') {
			<things to do here>
		}


OR, you could do it this way, also:

_NXXNXXXXXX  =>  {
		Set(areacode=${EXTEN:0:3})
		switch(${areacode})
		{
		case 404:
			<things to do here>
			break;
		case 770:
			<things to do here>
			break;
		case 678:
			<things to do here>
			break;
		}

This is, of course AEL code, and this stuff would be inside a context
construct...

murf






> 
> 
> Yours,
> 
> Michael Munger, dCAP
> 
> 404-438-2128
> 
> michael at highpoweredhelp.com
> 
>  
> 
> Attachment encrypted? click here.
> 
>  
> 
> 
> _______________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> 
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
-- 
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/20080221/d3cb268a/attachment.bin 


More information about the asterisk-users mailing list