[Freeswitch-users] LUA pattern match question

Chris Tunbridge blasterjr at gmail.com
Fri Jul 18 20:17:30 MSD 2014


err, followed by space(s) ending with spaces* sorry was typing faster than
i was thinking.


On Fri, Jul 18, 2014 at 10:17 AM, Chris Tunbridge <blasterjr at gmail.com>
wrote:

>  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
>
> More info here: http://lua-users.org/wiki/PatternsTutorial
>
>
> On Fri, Jul 18, 2014 at 10:10 AM, Sean Devoy <sdevoy at bizfocused.com>
> wrote:
>
>>  Hi All,
>>
>>
>>
>> I have modified this excellent example LUA script (
>> https://confluence.freeswitch.org/display/FREESWITCH/Lua+Intercom+example)
>> 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!
>>
>>
>>
>> My request is for someone to explain the pattern matching pattern used in
>> this function:
>>
>>     function trim (s)
>>
>>        return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
>>
>>     end
>>
>>
>>
>> It takes a string like this:
>>
>>
>> “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
>>
>> d7bd917c-efca-4333-81f6-692c727069a2,inbound,2014-07-18
>> 11:59:41,1405699181,sofia/external_noauth/4107673000 at 66.241.96.237
>> ,CS_EXECUTE,+14107673000,4107673000,66.241.96.237,BOOKKEEPING,voicemail,default
>> voicemail_ESTA 40,XML,from-internal-ESTA,L16,8000,128000,PCMU,8000,64000,,
>> fs_bfis.bizfocused.com,4107673000 at 66.241.96.237,,ACTIVE,,,,,,
>>
>>
>>
>> 1 total.”
>>
>>
>>
>> or just this:
>>
>>>>
>> 0 total.”
>>
>>
>>
>> And returns just the number and the “Total.” at the end, like “1 total.”
>> Or “0 total.”
>>
>>
>>
>> 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.
>>
>>
>>
>> Thanks as always,
>>
>> Sean
>>
>> _________________________________________________________________________
>> Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>>
>> 
>> 
>>
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.freeswitch.org
>> http://www.cluecon.com
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20140718/430f0bdd/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list