NOT in dialplan expression
Hi! How do I do a NOT equal to in a dialplan expression Normaly in regex I would use the ! character. This doesn't seem to work in FS.. ie <condition field="${variable}" expression="!^1"> Shouldn't that match when the variable is not starting with one?
it depends of what you are trying to acheave.... one approach is with regex check this: http://wiki.freeswitch.org/wiki/Misc._Dialplan_Tools_regex you can set a different variable and have it true or false ... than you can compare for false state... well .. it is up to you ... T. On Wed, Oct 21, 2009 at 1:34 PM, Mark Campbell-Smith < mcampbellsmith@gmail.com> wrote:
Hi!
How do I do a NOT equal to in a dialplan expression
Normaly in regex I would use the ! character. This doesn't seem to work in FS..
ie <condition field="${variable}" expression="!^1">
Shouldn't that match when the variable is not starting with one?
_______________________________________________ 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
Hi, Negating is done with [^...] in a regex, so 'not 1' is matched with: /^[^1]$/ If you want to match on a longer sequence, you can do that with negative lookahead, for example 'not 123' can be matched like this: /^(?!123$)\d{3}$/ regards, Leon On Oct 21, 2009, at 1:34 PM, Mark Campbell-Smith wrote:
Hi!
How do I do a NOT equal to in a dialplan expression
Normaly in regex I would use the ! character. This doesn't seem to work in FS..
ie <condition field="${variable}" expression="!^1">
Shouldn't that match when the variable is not starting with one?
_______________________________________________ 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 can also look at using anti-action rather than action after the condition. condition == if action == then anti-action == else On Wed, Oct 21, 2009 at 6:34 AM, Mark Campbell-Smith <mcampbellsmith@gmail.com> wrote:
Hi!
How do I do a NOT equal to in a dialplan expression
Normaly in regex I would use the ! character. This doesn't seem to work in FS..
ie <condition field="${variable}" expression="!^1">
Shouldn't that match when the variable is not starting with one?
_______________________________________________ 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
-- -Rupa
On Wed, Oct 21, 2009 at 8:07 AM, Rupa Schomaker <rupa@rupa.com> wrote:
You can also look at using anti-action rather than action after the condition.
condition == if action == then anti-action == else
Rupa & Leon, Nice job of explaining the options. Sometimes we forget about the powerful constructs that are available in FreeSWITCH and PCRE. karma++ for both of you. :) -MC
Thanks Guys for your suggestions! Very much appreciated. The reason I asked was that I want to check if a variable is set or not. I don't think your suggestions will work because I actually have to check to see an undefined variable. Any way to do this? I want to have the same extension for checking digits read from DTMF. The problem is that the digits are not set to the variable until the transfer statement, which means I would require 2 extensions. It will make things simpler if I can have the same extension that reads the digits and then checks them. For example: <extension name="checkdigits"> <condition field="destination_number" expression="^checkdigits$"/> <!--The next condition should be true if the variable $digits is not set/undefined --> <condition field="${digits}" expression="^[^.+]$" /> -----<<<< what should be here to check for undefined variable $digits ? <action application="read" data="1 10 ivr/ivr-hello.wav digits 10000 #"/> <action application="phrase" data="spell,${digits}"/> <action application="transfer" data="checkdigits digits XML features"/> </condition> <condition field="${pincode}" expression="^${some_variable}$"> < SOME ACTIONS HERE > </condition> </extension> On Thu, Oct 22, 2009 at 4:44 AM, Michael Collins <msc@freeswitch.org> wrote:
On Wed, Oct 21, 2009 at 8:07 AM, Rupa Schomaker <rupa@rupa.com> wrote:
You can also look at using anti-action rather than action after the condition.
condition == if action == then anti-action == else
Rupa & Leon,
Nice job of explaining the options. Sometimes we forget about the powerful constructs that are available in FreeSWITCH and PCRE. karma++ for both of you. :) -MC
_______________________________________________ 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
On Wed, Oct 21, 2009 at 3:51 PM, Mark Campbell-Smith < mcampbellsmith@gmail.com> wrote:
Thanks Guys for your suggestions! Very much appreciated.
The reason I asked was that I want to check if a variable is set or not. I don't think your suggestions will work because I actually have to check to see an undefined variable. Any way to do this?
Not in the dialplan itself. Better off using a script for this.
I want to have the same extension for checking digits read from DTMF. The problem is that the digits are not set to the variable until the transfer statement, which means I would require 2 extensions. It will make things simpler if I can have the same extension that reads the digits and then checks them.
You need either to use multiple extensions or use a script. The dialplan was specifically designed not to be a programming language and the functionality you seek is best served by using a script or by using transfer to drop the call through the diaplan again and use another extension. -MC
For example:
<extension name="checkdigits"> <condition field="destination_number" expression="^checkdigits$"/> <!--The next condition should be true if the variable $digits is not set/undefined --> <condition field="${digits}" expression="^[^.+]$" /> -----<<<< what should be here to check for undefined variable $digits ? <action application="read" data="1 10 ivr/ivr-hello.wav digits 10000 #"/> <action application="phrase" data="spell,${digits}"/> <action application="transfer" data="checkdigits digits XML features"/> </condition>
<condition field="${pincode}" expression="^${some_variable}$"> < SOME ACTIONS HERE > </condition> </extension>
Like rupa said, use anti-action? Remember FreeSWITCH XML dialplan is not a programming language it's a pre-processor routing markup Se potential use of anti-action below: <extension name="checkdigits"> <condition field="destination_number" expression="^checkdigits$"/> <!--The next condition should be true if the variable $digits is not set/undefined --> <condition field="${digits}" expression="^[^.+]$" /> -- <action application="read" data="1 10 ivr/ivr-hello.wav digits 10000 #"/> <action application="phrase" data="spell,${digits}"/> <action application="transfer" data="checkdigits digits XML features"/> <anti-action application="set" data="not_true=true"/> </condition> <condition field="${pincode}" expression="^${some_variable}$"> < SOME ACTIONS HERE > </condition> </extension> On Wed, Oct 21, 2009 at 5:51 PM, Mark Campbell-Smith < mcampbellsmith@gmail.com> wrote:
Thanks Guys for your suggestions! Very much appreciated.
The reason I asked was that I want to check if a variable is set or not. I don't think your suggestions will work because I actually have to check to see an undefined variable. Any way to do this?
I want to have the same extension for checking digits read from DTMF. The problem is that the digits are not set to the variable until the transfer statement, which means I would require 2 extensions. It will make things simpler if I can have the same extension that reads the digits and then checks them.
For example:
<extension name="checkdigits"> <condition field="destination_number" expression="^checkdigits$"/> <!--The next condition should be true if the variable $digits is not set/undefined --> <condition field="${digits}" expression="^[^.+]$" /> -----<<<< what should be here to check for undefined variable $digits ? <action application="read" data="1 10 ivr/ivr-hello.wav digits 10000 #"/> <action application="phrase" data="spell,${digits}"/> <action application="transfer" data="checkdigits digits XML features"/> </condition>
<condition field="${pincode}" expression="^${some_variable}$"> < SOME ACTIONS HERE > </condition> </extension>
On Thu, Oct 22, 2009 at 4:44 AM, Michael Collins <msc@freeswitch.org> wrote:
On Wed, Oct 21, 2009 at 8:07 AM, Rupa Schomaker <rupa@rupa.com> wrote:
You can also look at using anti-action rather than action after the condition.
condition == if action == then anti-action == else
Rupa & Leon,
Nice job of explaining the options. Sometimes we forget about the
powerful
constructs that are available in FreeSWITCH and PCRE. karma++ for both of you. :) -MC
_______________________________________________ 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
_______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
participants (6)
-
Anthony Minessale
-
Leon de Rooij
-
Mark Campbell-Smith
-
Michael Collins
-
Rupa Schomaker
-
Tihomir Culjaga