[SR-Dev] About regular expression syntax

Iñaki Baz Castillo ibc at aliax.net
Tue Mar 24 18:50:09 CET 2009


Hi, Kamailio uses the following syntax for =~ operator:

  if ( $rU =~ "^2[0-9]{2}$" ) {

Reading the SR commits, it seems that SR will support regular
expressions in 'switch' stament:

   switch ($rU) {
   case 200:   # INTEGER
      [...]
   case "alice":   # STRING
      [...]
   case /2[0-9]{2}/:   # REGULAR EXPRESSION
      [...]
   }

If the above is correct, it requires two different syntax for a
regular expression:
a)  =~ "^2[0-9]{2}$"
b)  case  /2[0-9]{2}/:

Wouldn't make sense to have an unique syntax for regular expressions?
IMHO the best one is:
   /2[0-9]{2}/

so =~ would use:
   if ( $rU =~ /^2[0-9]{2}$/ ) {

Opinions? Regards.


-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the sr-dev mailing list