Hi Michael,<div><br></div><div>I have another question for you and I REALLY REALLY apologise for abusing you as a Regex teacher but I have spent 2 hrs on this and can't figure out why this isn't working and believe me I have tried SEVERAL combinations but I can't make this work. </div>
<div><br></div><div>the question is, why does the regex</div><div><br></div><div>^\+?1?(0[0-1]+)?([32|48|54|55|65]\d+)\;?(phone-context=)?\+?(\d+)?$</div><div><div><br></div><div>match</div><div><br></div><div>414xxxxxxxx;phone-context=+41</div>
<div><br></div><div>The intention is to ONLY match numbers that may be</div><div><br></div><div>+32xxxxxxxxxxxxx, 032xxxxxxxxxxx,01132xxxxxxxxxxxxxx,+01132xxxxxxxxxxxx</div><div>+48xxxxxxxxxxxxx, 048xxxxxxxxxxx,01148xxxxxxxxxxxxxx,+01148xxxxxxxxxxxx</div>
<div>+54xxxxxxxxxxxxx, 054xxxxxxxxxxx,01154xxxxxxxxxxxxxx,+01154xxxxxxxxxxxx</div><div>etc.</div><div><br></div><div>why's it matching a number starting with 41?</div><div><br></div><div>Is this incorrect RegEx implementation in FS or do I not get Regex? </div>
<div><br></div><div>Sorry, I'll understand if you don't want to respond or help :)</div><div><br></div><div>Thanks</div><div>RR</div><div> </div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Wed, May 26, 2010 at 1:40 AM, Michael S Collins <span dir="ltr"><<a href="mailto:msc@freeswitch.org">msc@freeswitch.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div bgcolor="#FFFFFF"><div>It's all good. Now you have to pay it forward. :)</div><div>-MC<br><br>Sent from my iPhone</div>
<div><div></div><div class="h5"><div><br>On May 25, 2010, at 9:34 PM, RR <<a href="mailto:ranjtech@gmail.com" target="_blank">ranjtech@gmail.com</a>> wrote:<br><br></div><div></div><blockquote type="cite"><div>Michael,<div>
<br></div><div>Thank you SO SO much for the help. Your regex work perfectly as desired. I had tried what you suggested earlier but I think I might've made a mistake somewhere because I wasn't getting the right results so I resorted to doing the "|" between the prefixes to strip them out thinking maybe FS works by going if it begins + OR +1 OR 011 then remove them but I guess it doesn't as when "\" appears it uses / matches against only the first one of the those as opposed to all of those. </div>
<div><br></div><div>Thanks again and sorry for wasting your time ;)</div><div><br></div><div>Cheers</div><div>RR<br><br><div class="gmail_quote">On Tue, May 25, 2010 at 9:19 PM, Michael Collins <span dir="ltr"><<a href="mailto:msc@freeswitch.org" target="_blank"></a><a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><div>On Tue, May 25, 2010 at 5:44 PM, RR <span dir="ltr"><<a href="mailto:ranjtech@gmail.com" target="_blank"></a><a href="mailto:ranjtech@gmail.com" target="_blank">ranjtech@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Michael, haha, yeah they indeed are. That's why I'm routing based on $2, but I still see the 1 and/or the 011 going through to the "bridge" application. Why??<br></blockquote></div><div>Because your regex is wrong. :) It took me a while to figure it out. I'm surprised it worked at all. All the stuff you have inside the first set of parens is not behaving the way you think it should be. If I read your intentions correctly you're trying to strip off leading:<br>
+<br>OR<br>+1<br>OR<br>1<br><br>In the first regex. Correct? If ANI is NANPA-ish then try this in your first regex:<br>^\+?1?([2-9]\d+).*$<br><br>That should strip off leading + and/or 1 and capture just the 10-digit phone number in $1. (Be sure to use $1 and not $2, unless you had your heart set on using $2 in which case wrap the first part of the regex in parens)<br>
<br>The other regex is also tricky. I assume you are trying to strip off the same as above as well as 011? Try this:<br>^\+?1?(011)?([2-9]\d+).*$<br>
<br>Again, if the phone number in question is NANPA then $2 should contain just the 10 digits you want. Play around with that and let us know what happens. Also, don't forget what I said about using regex from the fs_cli. You can test all this stuff yourself. :)<br>
<font color="#888888">
<br>-MC<br><br><br> <br></font></div><div><div></div><div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><br><div class="gmail_quote">
<div><div></div><div>On Tue, May 25, 2010 at 8:34 PM, Michael Collins <span dir="ltr"><<a href="mailto:msc@freeswitch.org" target="_blank"></a><a href="mailto:msc@freeswitch.org" target="_blank">msc@freeswitch.org</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div><br><br><div class="gmail_quote"><div><div></div>
<div>On Tue, May 25, 2010 at 5:27 PM, RR <span dir="ltr"><<a href="mailto:ranjtech@gmail.com" target="_blank"></a><a href="mailto:ranjtech@gmail.com" target="_blank">ranjtech@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Ok, so I take that back. This seems to only work when the dialplan has a specific ANI and DNIS / destination_number / sip_to_user defined. If this is more general<div><br></div><div>like </div><div><br></div><div><div><include></div>
<div> <extension name="public_did"></div><div> <condition field="ani" expression="^(\+?|\+1?|1?)(\d+).*$" break="never"></div><div> <action application="set" data="effective_caller_id_number=$2"/></div>
<div> <action application="set" data="effective_caller_id_name=$2"/></div><div> </condition></div><div> <condition field="${sip_to_user}" expression="^(\+1?|\+|1?|011?)(\d+).*$" break="never"></div>
<div> <action application="set" data="continue_on_fail=false"/></div><div> <action application="set" data="hangup_after_bridge=true"/></div><div> <action application="set" data="domain_name=$${domain}"/></div>
<div> <action application="set" data="bypass_media=true"/></div><div> <action application="limit_hash" data="in cc_blades 4200 !USER_BUSY"/></div><div> <action application="bridge" data="{sip_invite_domain=${sip_from_host}}sofia/gateway/${distributor(cc_blades)}/$2"/></div>
<div> </condition></div><div> </extension></div><div></include></div><div><br></div><div>then even though the expression/conditions seem to match, none of the digits are being stripped off. Shouldn't this be stripping off digits??</div>
<div><br></div><div>Here's the debug output:</div></div><div><br></div><div><div><div>Dialplan: sofia/external/16469NNNNNN Regex (PASS) [public_did] ani(16469NNNNNN;phone-context=+1) =~ /^(\+?|\+1?|1?)(\d+).*$/ break=never</div>
<div>Dialplan: sofia/external/16469NNNNNN Action set(effective_caller_id_number=16469NNNNNN)</div><div>Dialplan: sofia/external/16469NNNNNN Action set(effective_caller_id_name=16469NNNNNN)</div><div>Dialplan: sofia/external/16469NNNNNN Regex (PASS) [public_did] ${sip_to_user}(011390NNNNNNNNNN;phone-context=+39) =~ /^(\+1?|\+|1?|011?)(\d+).*$/ break=never</div>
<div>Dialplan: sofia/external/16469NNNNNN Action set(continue_on_fail=false)</div><div>Dialplan: sofia/external/16469NNNNNN Action set(hangup_after_bridge=true)</div><div>Dialplan: sofia/external/16469NNNNNN Action set(domain_name=208.72.186.166)</div>
<div>Dialplan: sofia/external/16469NNNNNN Action set(bypass_media=true)</div><div>Dialplan: sofia/external/16469NNNNNN Action limit_hash(in cc_blades 4200 !USER_BUSY)</div><div>Dialplan: sofia/external/16469NNNNNN Action bridge({sip_invite_domain=${sip_from_host}}sofia/gateway/${distributor(cc_blades)}/011390NNNNNNNNNN)</div>
<div><br></div><div>why're the '1' in the ANI and '011' in the DNIS/sip_to_user being stripped off???</div></div></div></blockquote></div></div><div><br>Regex 101 :)<br><br>The 1 or the 011 are in $1<br>
-MC<br></div>
</div><br>
<br></div></div>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank"></a><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"></a><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"></a><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"></a><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank"></a><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"></a><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"></a><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"></a><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank"></a><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"></a><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"></a><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"></a><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>FreeSWITCH-users mailing list</span><br><span><a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a></span><br>
<span><a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a></span><br><span>UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a></span><br>
<span><a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a></span><br></div></blockquote></div></div></div><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>