Below is the command to run the switch statement with regular expression in PowerShell.
switch -regex ('abcdef') {'abcdef' {"abc"} '123' {"123"} }
The above command found its match in the first case which is “abcdef” and thus “abc” will get printed out on the screen as follows:-
abc
A regular expression is often used to match the sophisticated pattern within a phrase or word.