Switch Statement with Regex Parameter

suggest change

The -Regex parameter allows switch statements to perform regular expression matching against conditions.

Example:

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'} 
}

Output:

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