[Freeswitch-users] Need help on regex
Tihomir Culjaga
tculjaga at gmail.com
Mon Oct 25 04:17:27 PDT 2010
On Sun, Oct 24, 2010 at 11:09 PM, mazilo <Nabble at slickdeals.endjunk.com>wrote:
>
> I am not much of a regex person but am looking for some help on crafting a
> simple regex filter that can do the following criterias:
>
> 1. The dialed number is always a 10-digits number, i.e. an area code +
> 7-digits number (without any leading digit(s) of +1 and/or 1).
>
> 2. If the 4-th digit of the dialed number (after the area code) is a
> non-zero number, do nothing. Otherwise, the regex filter will strip the
> leading 3 digits (area code) as well as the last 2 digits number and this
> will leave only 1-st 5-digits number (no area code). For instance, if the
> 10-digits dialed number is 0120123456, then the regex filter will return
> 01234. More examples followed:
>
> 10-digits input number output number
> --------------------- -------------
> 4120123456 01234
> 0121234567 0121234567
> 1310156434 01564
> 8231234567 8231234567
> 0126543210 0126543210
> Anyone? Thanks.
>
>
i'd say, this one:
<action application="set" data="myNUM=${cond(${destination_number:4:1} == 0
? ${regex(${destination_number}|\d{3}(0\d{4}).*|%1)} :
${destination_number})}"/>
i wrote it by hearth .. so you might tune it a bit ... but the basic is here
:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20101025/d58140d2/attachment.html
More information about the FreeSWITCH-users
mailing list