Regex capturing in nested conditions
Is there a way of referencing captured regex in the first condition of nested conditions? EG If I have: <extension name="8 prefix" continue="true"> <condition field="destination_number" expression="^8(0\d{9,15})"/> <condition field="${db(exists/${sip_from_user}/cli8}" expression="true"> <action application="set" data="destination_number=$1" inline="true"/> </condition> </extension> At the moment this doesn’t capture the number, and just gives me an actual ‘$1’. I guess I could rearrange the conditions, but I don’t want to break all my logic really…
$1 comes from the LAST regex ran. In this case last regex is looking for true w/ no () so there is nothing in $1 From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Rick Jarvis Sent: Tuesday, January 24, 2017 12:14 PM To: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org> Subject: [Freeswitch-users] Regex capturing in nested conditions Is there a way of referencing captured regex in the first condition of nested conditions? EG If I have: <extension name="8 prefix" continue="true"> <condition field="destination_number" expression="^8(0\d{9,15})"/> <condition field="${db(exists/${sip_from_user}/cli8}" expression="true"> <action application="set" data="destination_number=$1" inline="true"/> </condition> </extension> At the moment this doesn’t capture the number, and just gives me an actual ‘$1’. I guess I could rearrange the conditions, but I don’t want to break all my logic really…
Hi, try this: <extension name="8 prefix" continue="true"> <condition field="destination_number" expression="^8(0\d{9,15})"> <action application="set" data="dst_number=$1" inline="true"/> <condition field="${db(exists/${sip_from_user}/cli8}" expression="true"> <action application="set" data="destination_number=${dst_number}" inline="true"/> <action application="log" data="INFO ${dst_number} ${destination_number}"/> </condition> </condition> </extension> "destination_number" is a FreeSWITCH variable; it shouldn't be changed. Regards, Srigo
On Jan 24, 2017, at 7:14 PM, Rick Jarvis <rick@magicmail.mooo.com> wrote:
Is there a way of referencing captured regex in the first condition of nested conditions?
EG If I have:
<extension name="8 prefix" continue="true"> <condition field="destination_number" expression="^8(0\d{9,15})"/> <condition field="${db(exists/${sip_from_user}/cli8}" expression="true"> <action application="set" data="destination_number=$1" inline="true"/> </condition> </extension>
At the moment this doesn’t capture the number, and just gives me an actual ‘$1’. I guess I could rearrange the conditions, but I don’t want to break all my logic really… _________________________________________________________________________ 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
You cant overwrite destination_number with a set command, its not a channel variable, its an element on the caller profile struct. If you need to reset destination_number you must use the transfer application From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of KSrigo Sent: Wednesday, January 25, 2017 4:02 AM To: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Regex capturing in nested conditions Hi, try this: <extension name="8 prefix" continue="true"> <condition field="destination_number" expression="^8(0\d{9,15})"> <action application="set" data="dst_number=$1" inline="true"/> <condition field="${db(exists/${sip_from_user}/cli8}" expression="true"> <action application="set" data="destination_number=${dst_number}" inline="true"/> <action application="log" data="INFO ${dst_number} ${destination_number}"/> </condition> </condition> </extension> "destination_number" is a FreeSWITCH variable; it shouldn't be changed. Regards, Srigo On Jan 24, 2017, at 7:14 PM, Rick Jarvis <rick@magicmail.mooo.com <mailto:rick@magicmail.mooo.com> > wrote: Is there a way of referencing captured regex in the first condition of nested conditions? EG If I have: <extension name="8 prefix" continue="true"> <condition field="destination_number" expression="^8(0\d{9,15})"/> <condition field="${db(exists/${sip_from_user}/cli8}" expression="true"> <action application="set" data="destination_number=$1" inline="true"/> </condition> </extension> At the moment this doesn’t capture the number, and just gives me an actual ‘$1’. I guess I could rearrange the conditions, but I don’t want to break all my logic really… _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org <mailto: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 <mailto: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 (3)
-
Ken Rice
-
KSrigo
-
Rick Jarvis