Hello,
Is there any way to use Regex or 'OR/AND' operators in the switch/case statements? I've tried the following syntax but it's not working, are there any other ways to do this?
switch($dlg_var(ISP)) { case "TRUNK1|TRUNK2": }
Thank you.
I'm not sure if it's supported, but the usual way of doing this in other languages is:
switch(expr) { case CASE1: case CASE2: ... break;
case CASE3: ... }
-- Alex
On 8/17/20 1:46 PM, Ilie Soltanici wrote:
Hello,
Is there any way to use Regex or 'OR/AND' operators in the switch/case statements? I've tried the following syntax but it's not working, are there any other ways to do this?
switch($dlg_var(ISP)) { case"TRUNK1|TRUNK2": }
Thank you.
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
On Mon, 2020-08-17 at 13:48 -0400, Alex Balashov wrote:
I'm not sure if it's supported, but the usual way of doing this in other languages is:
switch(expr) { case CASE1: case CASE2: ... break; case CASE3: ... }
-- Alex
Why, yes... it is supported. =)
Example on line 724 of the default kamailio config:
https://github.com/kamailio/kamailio/blob/master/etc/kamailio.cfg
--fred
Yes, this way is much better than duplicating code for the same trunks. Thank's Alex.
On Mon, 17 Aug 2020 at 18:49, Alex Balashov abalashov@evaristesys.com wrote:
I'm not sure if it's supported, but the usual way of doing this in other languages is:
switch(expr) { case CASE1: case CASE2: ... break; case CASE3: ... }
-- Alex
On 8/17/20 1:46 PM, Ilie Soltanici wrote:
Hello,
Is there any way to use Regex or 'OR/AND' operators in the switch/case statements? I've tried the following syntax but it's not working, are there any other ways to do this?
switch($dlg_var(ISP)) { case"TRUNK1|TRUNK2": }
Thank you.
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
The example mentioned above is for integers, not for Regex.
Here's the syntax for regex matching with switch():
switch ( $var(myvar) ) { case /"^mystring1": // Do stuff break; case /"^mystring2": // Do other stuff break; default: // Default actions }
On Mon, 17 Aug 2020 at 21:18, Ilie Soltanici iliusha.md@gmail.com wrote:
Yes, this way is much better than duplicating code for the same trunks. Thank's Alex.
On Mon, 17 Aug 2020 at 18:49, Alex Balashov abalashov@evaristesys.com wrote:
I'm not sure if it's supported, but the usual way of doing this in other languages is:
switch(expr) { case CASE1: case CASE2: ... break; case CASE3: ... }
-- Alex
On 8/17/20 1:46 PM, Ilie Soltanici wrote:
Hello,
Is there any way to use Regex or 'OR/AND' operators in the switch/case statements? I've tried the following syntax but it's not working, are there any other ways to do this?
switch($dlg_var(ISP)) { case"TRUNK1|TRUNK2": }
Thank you.
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Alex Balashov | Principal | Evariste Systems LLC
Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users