Switch Statement with Regex Parameter

suggest change

-Regex compares the value with each condition as a regular expression. Matching is case-insensitive unless you also pass -CaseSensitive. Every matching condition runs.

The second pattern does not match. Conditio*$ must reach the end of the string, and Condition still has a final n.

switch -Regex ('Condition')
{
  'Con\D+ion'    {'One or more non-digits'}
  'Conditio*$'   {'Zero or more "o"'}
  'C.ndition'    {'Any single char.'}
  '^C\w+ition$'  {'Anchors and one or more word chars.'}
  'Test'         {'No match'}
}
One or more non-digits
Any single char.
Anchors and one or more word chars.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents