Reply To: Switch Command using variable for regexp

Clovertech Forums Read Only Archives Cloverleaf General Switch Command using variable for regexp Reply To: Switch Command using variable for regexp

#58081
Charlie Bursell
Participant

    You can not evaluate a variable inside braces like this.  You have to use a different style for the switch.  Try this:

    switch -regexp — $phone

          $style_1 {echo “Style 1 found”}

         {^[0-9][0-9]$} {echo “Style 2 found”}

         {^[0-9][0-9][0-9]$} {echo “Style 3 found”}

         {^[0-9][0-9][0-9][0-9]$} { echo “Style 4 found”}

         {^[0-9][0-9][0-9][0-9][0-9]$} {echo “Style 5 found”}

         default   {echo “Style default found} 8)