I have this expression in a switch statement for a script controlpanel
$ctrlinpt=read-host ">>>"
switch -regex ( $ctrlinpt )
{
<#1#>'^\w{2,}|\d{2,}$' { do this }
<#2#>'^c{1}|C{1}$' { do that }
<#3#>'^l{1}|L{1}$' { do somethign else }
<#4#>'^s{1}|S{1}$' { take a break }
<#5#>'^exit$'{ go home }
}
The first condition should match any input with more than one character and it does. However , if the input starts with one of the letters in the other conditions, it also matches their cases for example
"Task1" matches only case 1
"Legacy" matches case 1 and case 3
"supper" matches case 1 and case 4
I expect cases 2,3, and 4 to only match an input of exactly the one character stated. What am I doing wrong?