I am trying to check for invalid file names. I want the file name to contain only lowercase, uppercase, numbers, spaces, periods, underscores, dashes and parentheses. I tried this regex:
$regex = [regex]"^([a-zA-Z0-9\s\._-\)\(]+)$" $text = "hel()lo" if($text -notmatch $regex) { write-host 'not valid' }
I get this error:
Error: "parsing "^([a-zA-Z0-9\s\._-\)\(]+)$" - [xy] range in reverse order"
What am I doing wrong?
Steve source share