<div dir="ltr">?: means "match but don't save it", for when [] just isn't flexible enough.<div><br><div><span style="font-family:Verdana,Arial,Helvetica,sans-serif">-Avi</span><br><br><div class="gmail_quote">
On Thu, Jan 10, 2013 at 12:53 AM, Sean Devoy <span dir="ltr"><<a href="mailto:sdevoy@bizfocused.com" target="_blank">sdevoy@bizfocused.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hey Avi,<u></u><u></u></span></p><p class="MsoNormal">
<span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Using your regex: </span><span style="font-family:"Arial","sans-serif"">^(?:1|\+1|001)?([2-9]\d\d[2-9]\d{6})$</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Doesn’t $1 match the stuff in the first set of () and $2 match my needed 10 digits?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Sean<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a> [mailto:<a href="mailto:freeswitch-users-bounces@lists.freeswitch.org" target="_blank">freeswitch-users-bounces@lists.freeswitch.org</a>] <b>On Behalf Of </b>Avi Marcus<br>
<b>Sent:</b> Wednesday, January 09, 2013 3:02 PM</span></p><div class="im"><br><b>To:</b> FreeSWITCH Users Help<br><b>Subject:</b> Re: [Freeswitch-users] xml dialplan - regurlar expression question / Sanity Check!<u></u><u></u></div>
<p></p><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Ha, that was a tricky one!<u></u><u></u></p><div><div class="h5"><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Here's the issue - he dialed: <span style="font-family:"Arial","sans-serif";background:white">1-800-336-940 -- that's too few digits!</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif";background:white">So your optional one made it match anyway.</span><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p>
</div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif";background:white">Your matching is too allowing - here's the regex I use:</span><u></u><u></u></p></div><div><p class="MsoNormal">
<u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">^(?:1|\+1|001)?([2-9]\d\d[2-9]\d{6})$</span><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p>
</div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">That matches [nothing, 1, +1 or 001] prefix for USA. Then, bridge like now to "1$1".</span><u></u><u></u></p></div>
<div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Arial","sans-serif"">btw, if you want a separate match for USA toll-free it's: ^(?:1|\+1|001)?(8(00|55|66|77|88)[2-9]\d{6})$</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">There's also some good example on this page, the link goes directly to USA: <a href="http://wiki.freeswitch.org/wiki/Regular_Expression#NANPA_.2B1NxxNxxXXXX_E.164_Dialstring" target="_blank">http://wiki.freeswitch.org/wiki/Regular_Expression#NANPA_.2B1NxxNxxXXXX_E.164_Dialstring</a><u></u><u></u></p>
</div><div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><div><p class="MsoNormal"><span style="font-family:"Verdana","sans-serif"">-Avi Marcus</span><br>BestFone<u></u><u></u></p></div>
</div>
<p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Wed, Jan 9, 2013 at 9:48 PM, Sean Devoy <<a href="mailto:sdevoy@bizfocused.com" target="_blank">sdevoy@bizfocused.com</a>> wrote:<u></u><u></u></p>
<div><div><p class="MsoNormal">HI,<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">I really hope this question is not as dumb as some of my recent questions (Anybody else wiped out you O/S lately?)!<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">Anyway, I have an xml dial plan:<u></u><u></u></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">extension</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">name</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">ten_or eleven_digiti_dial</span>"<span style="color:blue"> ></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">condition</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">field</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">destination_number</span>"<span style="color:blue"> </span><span style="color:red">expression</span><span style="color:blue">=</span>"<span style="color:blue">^1?(\d{10})$</span>"<span style="color:blue">></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">action</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">application</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">set</span>"<span style="color:blue"> </span><span style="color:red">data</span><span style="color:blue">=</span>"<span style="color:blue">ringback=${us-ring}</span>"<span style="color:blue">/></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">action</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">application</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">set</span>"<span style="color:blue"> </span><span style="color:red">data</span><span style="color:blue">=</span>"<span style="color:blue">effective_caller_id_number=${outbound_caller_id_number}</span>"<span style="color:blue">/></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">action</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">application</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">set</span>"<span style="color:blue"> </span><span style="color:red">data</span><span style="color:blue">=</span>"<span style="color:blue">ani=${outbound_caller_id_number}</span>"<span style="color:blue">/></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">action</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">application</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">set</span>"<span style="color:blue"> </span><span style="color:red">data</span><span style="color:blue">=</span>"<span style="color:blue">effective_caller_id_name=${outbound_caller_id_name}</span>"<span style="color:blue">/></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">action</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">application</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">set</span>"<span style="color:blue"> </span><span style="color:red">data</span><span style="color:blue">=</span>"<span style="color:blue">hangup_after_bridge=true</span>"<span style="color:blue">/></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> <</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">action</span><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </span><span style="font-size:9.5pt;font-family:Consolas;color:red">application</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">=</span><span style="font-size:9.5pt;font-family:Consolas">"<span style="color:blue">bridge</span>"<span style="color:blue"> </span><span style="color:red">data</span><span style="color:blue">=</span>"<span style="color:blue">sofia/gateway/vitelity-inbound/1$1</span>"<span style="color:blue">/></span></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">condition</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">></span><u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"> </</span><span style="font-size:9.5pt;font-family:Consolas;color:#a31515">extension</span><span style="font-size:9.5pt;font-family:Consolas;color:blue">></span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">I thought that would accept either 10 or 11 digit numbers starting with 1 and bridge to the gateway always using 1 plus the 10 digits.<u></u><u></u></p><p class="MsoNormal">
<u></u><u></u></p><p class="MsoNormal">In fact in my log I can see:<u></u><u></u></p><p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Regex <b><span style="color:red">(PASS)</span></b> [ten_or eleven_digiti_dial] destination_number<b><span style="color:red"><a href="tel:(14104207777" target="_blank">(14104207777</a></span></b>) =~ /^1?(\d{10})$/ break=on-false<u></u><u></u></p>
<p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action set(ringback=${us-ring}) <u></u><u></u></p><p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action set(effective_caller_id_number=${outbound_caller_id_number}) <u></u><u></u></p>
<p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action set(ani=${outbound_caller_id_number}) <u></u><u></u></p><p class="MsoNormal">
Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action set(effective_caller_id_name=${outbound_caller_id_name}) <u></u><u></u></p><p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action set(hangup_after_bridge=true) <u></u><u></u></p>
<p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action bridge<b><span style="color:red">(sofia/gateway/vitelity-inbound/<a href="tel:14104207777" target="_blank">14104207777</a></span></b>)<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal"><b><span style="color:red">BUT</span></b><u></u><u></u></p><p class="MsoNormal">It does not work for my customer :<u></u><u></u></p><p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:101@fs_alst.bizfocused.com" target="_blank">101@fs_alst.bizfocused.com</a> Regex <b><span style="color:red">(PASS</span></b>) [ten_or_eleven_digiti_dial] destination_number(<b><span style="color:red">1800336940</span></b>) =~ /^1?(\d{10})$/ break=on-false<u></u><u></u></p>
<p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:101@fs_alst.bizfocused.com" target="_blank">101@fs_alst.bizfocused.com</a> Action set(ringback=${us-ring}) <u></u><u></u></p><p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:101@fs_alst.bizfocused.com" target="_blank">101@fs_alst.bizfocused.com</a> Action set(effective_caller_id_number=${outbound_caller_id_number}) <u></u><u></u></p>
<p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:101@fs_alst.bizfocused.com" target="_blank">101@fs_alst.bizfocused.com</a> Action set(ani=${outbound_caller_id_number}) <u></u><u></u></p><p class="MsoNormal">
Dialplan: sofia/external/<a href="mailto:101@fs_alst.bizfocused.com" target="_blank">101@fs_alst.bizfocused.com</a> Action set(effective_caller_id_name=${outbound_caller_id_name}) <u></u><u></u></p><p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:220@fs_bfis.bizfocused.com" target="_blank">220@fs_bfis.bizfocused.com</a> Action set(hangup_after_bridge=true) <u></u><u></u></p>
<p class="MsoNormal">Dialplan: sofia/external/<a href="mailto:101@fs_alst.bizfocused.com" target="_blank">101@fs_alst.bizfocused.com</a> Action bridge<b><span style="color:red">(sofia/gateway/vitelity-inbound/11800336940</span></b>) <span style="background:yellow">NOTE THE EXTRA LEADING 1</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">So, what am I missing?<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">Thanks,<u></u><u></u></p><p class="MsoNormal">Sean<u></u><u></u></p>
</div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>_________________________________________________________________________<br>Professional FreeSWITCH Consulting Services:<br><a href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com/" target="_blank">http://www.freeswitchsolutions.com</a><br><br>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br><a href="http://www.cudatel.com/" target="_blank">http://www.cudatel.com</a><br>
<br>Official FreeSWITCH Sites<br><a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org</a><br><a href="http://wiki.freeswitch.org/" target="_blank">http://wiki.freeswitch.org</a><br><a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com</a><br>
<br>FreeSWITCH-users mailing list<br><a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br><a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org</a><u></u><u></u></p>
</div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div><br>_________________________________________________________________________<br>
Professional FreeSWITCH Consulting Services:<br>
<a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
<a href="http://www.freeswitchsolutions.com/" target="_blank">http://www.freeswitchsolutions.com</a><br>
<br>
FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>
<a href="http://www.cudatel.com/" target="_blank">http://www.cudatel.com</a><br>
<br>
Official FreeSWITCH Sites<br>
<a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org</a><br>
<a href="http://wiki.freeswitch.org/" target="_blank">http://wiki.freeswitch.org</a><br>
<a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com</a><br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div></div></div>