<div dir="ltr"><div> From my experience with lua its treating %s as any whitespace, starts with any number of spaces, then it says anything after the spaces non greedy, then followed by a string, ending with that string<br>

<br></div>More info here: <a href="http://lua-users.org/wiki/PatternsTutorial">http://lua-users.org/wiki/PatternsTutorial</a><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 10:10 AM, Sean Devoy <span dir="ltr">&lt;<a href="mailto:sdevoy@bizfocused.com" target="_blank">sdevoy@bizfocused.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div>
<p class="MsoNormal">Hi All,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have modified this excellent example LUA script (<a href="https://confluence.freeswitch.org/display/FREESWITCH/Lua+Intercom+example" target="_blank">https://confluence.freeswitch.org/display/FREESWITCH/Lua+Intercom+example</a>) to return “true” if an
 extension is in use and “false” otherwise”.  Just FYI: this is great for Cisco phones because an auto-answer (intercom) connection will interrupt the current call unless you block ALL intercom use.  With this I can sent intercom if not in use, or send as a
 standard call otherwise.  My complements to the original chef!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My request is for someone to explain the pattern matching pattern used in this function:<u></u><u></u></p>
<p class="MsoNormal" style="line-height:15.0pt"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#333333">    function trim (s)</span><span style="font-size:10.5pt;font-family:Consolas;color:#333333"><u></u><u></u></span></p>


<p class="MsoNormal" style="line-height:15.0pt"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#333333">       return (string.gsub(s, &quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;))</span><span style="font-size:10.5pt;font-family:Consolas;color:#333333"><u></u><u></u></span></p>


<p class="MsoNormal" style="line-height:15.0pt"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:#333333">    end</span><span style="font-size:10.5pt;font-family:Consolas;color:#333333"><u></u><u></u></span></p>


<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">It takes a string like this:<u></u><u></u></p>
<p class="MsoNormal">“uuid,direction,created,created_epoch,name,state,cid_name,cid_num,ip_addr,dest,application,application_data,dialplan,context,read_codec,read_rate,read_bit_rate,write_codec,write_rate,write_bit_rate,secure,hostname,presence_id,presence_data,callstate,callee_name,callee_num,callee_direction,call_uuid,sent_callee_name,sent_callee_num<u></u><u></u></p>


<p class="MsoNormal">d7bd917c-efca-4333-81f6-692c727069a2,inbound,2014-07-18 11:59:41,1405699181,sofia/external_noauth/<a href="mailto:4107673000@66.241.96.237" target="_blank">4107673000@66.241.96.237</a>,CS_EXECUTE,+14107673000,4107673000,66.241.96.237,BOOKKEEPING,voicemail,default voicemail_ESTA 40,XML,from-internal-ESTA,L16,8000,128000,PCMU,8000,64000,,<a href="http://fs_bfis.bizfocused.com" target="_blank">fs_bfis.bizfocused.com</a>,<a href="mailto:4107673000@66.241.96.237" target="_blank">4107673000@66.241.96.237</a>,,ACTIVE,,,,,,<u></u><u></u></p>


<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">1 total.”<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">or just this:<u></u><u></u></p>
<p class="MsoNormal">“<u></u><u></u></p>
<p class="MsoNormal">0 total.”<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">And returns just the number and the “Total.” at the end, like “1 total.” Or “0 total.”<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am fairly regex pattern savvy so I understand pattern matching, but I cannot decipher this LUA pattern.  I see it works, but I would like to understand how/why.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks as always,<u></u><u></u></p>
<p class="MsoNormal">Sean <u></u><u></u></p>
</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>