Freeswitch - Regular Expression in Condition
I have this condition on a dialplan: <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}),(\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true"> <action application="set" inline="true" data="auto_hunt=true"/> <action application="transfer" data="${num_dest} XML routing.Saliente"/>And this curl response:+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000But I do not get the transfer, the regular expression is not working.I tried this and if it works:<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5})(,(\w*))*$" break="on-true"> <action application="set" inline="true" data="auto_hunt=true"/> <action application="transfer" data="${num_dest} XML routing.Saliente"/>The problem is from the fourth comma Desperate, I tried it with this conditions and does not work! <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),CUB281281,CUB301993,OP024000$" break="on-true"> and <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true"> Any ideas??
If you are going to go thru all this trouble why not just use mod_xml_curl and get back the dialplan that needs to be executed in the first place. the dialplan is not meant to be a scripting language itself. From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ximo Peral Sent: Thursday, October 15, 2015 11:54 AM To: freeswitch-users@lists.freeswitch.org Subject: [Freeswitch-users] Freeswitch - Regular Expression in Condition I have this condition on a dialplan: <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}), (\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\ d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}| ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|C UB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true"> <action application="set" inline="true" data="auto_hunt=true"/> <action application="transfer" data="${num_dest} XML routing.Saliente"/> And this curl response: +34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000 But I do not get the transfer, the regular expression is not working. I tried this and if it works: <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d {3,5})(,(\w*))*$" break="on-true"> <action application="set" inline="true" data="auto_hunt=true"/> <action application="transfer" data="${num_dest} XML routing.Saliente"/> The problem is from the fourth comma Desperate, I tried it with this conditions and does not work! <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d {3,5}),CUB281281,CUB301993,OP024000$" break="on-true"> and <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d {3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true"> Any ideas??
Or try parse curl response in lua script. On Thu, Oct 15, 2015, 19:59 Ken Rice <krice@freeswitch.org> wrote:
If you are going to go thru all this trouble why not just use mod_xml_curl and get back the dialplan that needs to be executed in the first place… the dialplan is not meant to be a scripting language itself.
*From:* freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] *On Behalf Of *Ximo Peral *Sent:* Thursday, October 15, 2015 11:54 AM *To:* freeswitch-users@lists.freeswitch.org *Subject:* [Freeswitch-users] Freeswitch - Regular Expression in Condition
I have this condition on a dialplan:
<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}),(\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true">
<action application="set" inline="true" data="auto_hunt=true"/>
<action application="transfer" data="${num_dest} XML routing.Saliente"/>
And this curl response:
+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000
But I do not get the transfer, the regular expression is not working.
I tried this and if it works:
<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5})(,(\w*))*$" break="on-true">
<action application="set" inline="true" data="auto_hunt=true"/>
<action application="transfer" data="${num_dest} XML routing.Saliente"/>
The problem is from the fourth comma
Desperate, I tried it with this conditions and does not work!
*<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),CUB281281,CUB301993,OP024000$" break="on-true">*
and
*<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true">*
Any ideas?? _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
But the expression is malformed? The dialplan is very big for editing now. From: s.safarov@gmail.com Date: Thu, 15 Oct 2015 17:08:59 +0000 To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Freeswitch - Regular Expression in Condition Or try parse curl response in lua script. On Thu, Oct 15, 2015, 19:59 Ken Rice <krice@freeswitch.org> wrote: If you are going to go thru all this trouble why not just use mod_xml_curl and get back the dialplan that needs to be executed in the first place… the dialplan is not meant to be a scripting language itself. From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Ximo Peral Sent: Thursday, October 15, 2015 11:54 AM To: freeswitch-users@lists.freeswitch.org Subject: [Freeswitch-users] Freeswitch - Regular Expression in Condition I have this condition on a dialplan: <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}),(\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true"><action application="set" inline="true" data="auto_hunt=true"/><action application="transfer" data="${num_dest} XML routing.Saliente"/>And this curl response:+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000But I do not get the transfer, the regular expression is not working.I tried this and if it works:<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5})(,(\w*))*$" break="on-true"><action application="set" inline="true" data="auto_hunt=true"/><action application="transfer" data="${num_dest} XML routing.Saliente"/>The problem is from the fourth comma Desperate, I tried it with this conditions and does not work! <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),CUB281281,CUB301993,OP024000$" break="on-true"> and <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true"> Any ideas??_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
971234567 is 9 digits but you're matching 10-23 digits in that section. On 15 October 2015 at 17:54, Ximo Peral <ximop_22@hotmail.com> wrote:
I have this condition on a dialplan:
<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}),(\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true"><action application="set" inline="true" data="auto_hunt=true"/><action application="transfer" data="${num_dest} XML routing.Saliente"/>
And this curl response:
+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000
But I do not get the transfer, the regular expression is not working.
I tried this and if it works:
<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5})(,(\w*))*$" break="on-true"><action application="set" inline="true" data="auto_hunt=true"/><action application="transfer" data="${num_dest} XML routing.Saliente"/>
The problem is from the fourth comma
Desperate, I tried it with this conditions and does not work!
*<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),CUB281281,CUB301993,OP024000$" break="on-true">*
and
*<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true">*
Any ideas??
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Nevermind, it won't match on the 6 digit part and will on the 4-17 part. Your regex is fine and matches that string. So the problem is likely elsewhere. How is curl_response_data set? Is it set before the hunting phase? If you're fetching it during the execution of the dialplan then it won't work, you'll need to transfer to trigger a new dialplan hunt. You can see what the string it's comparing to the regex is in the DEBUG-level logs, where you'll see it evaluating the extensions/conditions in the dialplan. On 16 October 2015 at 21:31, Steven Ayre <steveayre@gmail.com> wrote:
971234567 is 9 digits but you're matching 10-23 digits in that section.
On 15 October 2015 at 17:54, Ximo Peral <ximop_22@hotmail.com> wrote:
I have this condition on a dialplan:
<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}),(\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true"><action application="set" inline="true" data="auto_hunt=true"/><action application="transfer" data="${num_dest} XML routing.Saliente"/>
And this curl response:
+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000
But I do not get the transfer, the regular expression is not working.
I tried this and if it works:
<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5})(,(\w*))*$" break="on-true"><action application="set" inline="true" data="auto_hunt=true"/><action application="transfer" data="${num_dest} XML routing.Saliente"/>
The problem is from the fourth comma
Desperate, I tried it with this conditions and does not work!
*<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),CUB281281,CUB301993,OP024000$" break="on-true">*
and
*<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true">*
Any ideas??
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I use a: <action application = "log" data ="${curl_response_data}"/> to see in the xml cdr the curl_response_data variable. Exactly: "+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000" The curl request is executed in the same dialplan, this is the first action. From: steveayre@gmail.com Date: Fri, 16 Oct 2015 21:35:24 +0100 To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Freeswitch - Regular Expression in Condition Nevermind, it won't match on the 6 digit part and will on the 4-17 part. Your regex is fine and matches that string. So the problem is likely elsewhere. How is curl_response_data set? Is it set before the hunting phase? If you're fetching it during the execution of the dialplan then it won't work, you'll need to transfer to trigger a new dialplan hunt. You can see what the string it's comparing to the regex is in the DEBUG-level logs, where you'll see it evaluating the extensions/conditions in the dialplan. On 16 October 2015 at 21:31, Steven Ayre <steveayre@gmail.com> wrote: 971234567 is 9 digits but you're matching 10-23 digits in that section. On 15 October 2015 at 17:54, Ximo Peral <ximop_22@hotmail.com> wrote: I have this condition on a dialplan: <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{4,17}),(\d{3,5}),(\d{3,5}),(NP\d{3}|RG\d{4,8}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3}|TLSIOS),?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?,?(NP\d{3}|OP\d{6}|CUB\d{6}|CF\d{1}|ANF\d{3})?$" break="on-true"> <action application="set" inline="true" data="auto_hunt=true"/> <action application="transfer" data="${num_dest} XML routing.Saliente"/>And this curl response:+34987654321,971234567,000,00001,CUB281281,CUB301993,OP024000But I do not get the transfer, the regular expression is not working.I tried this and if it works:<condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5})(,(\w*))*$" break="on-true"> <action application="set" inline="true" data="auto_hunt=true"/> <action application="transfer" data="${num_dest} XML routing.Saliente"/>The problem is from the fourth comma Desperate, I tried it with this conditions and does not work! <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),CUB281281,CUB301993,OP024000$" break="on-true"> and <condition field="${curl_response_data}" expression="^(\+)?(\d{6})?(\d{4,15}|anonymous),(\d{6})?(\d{9}),(\d{3,5}),(\d{3,5}),(CUB281281),(CUB301993),(OP024000)$" break="on-true"> Any ideas?? _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
participants (4)
-
Ken Rice
-
Sergey Safarov
-
Steven Ayre
-
Ximo Peral