该-Regex参数允许switch语句针对条件执行正则表达式匹配。
例:
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.