NegativeMatchingTest.ps1 $var="The-quick-brown-fox-jumped-over-the-lazy-dog." $var2="The quick brown fox jumped over the lazy dog." $regex=[regex]"\s{1}" $var if (($regex.IsMatch($var)) -eq "False") { write-host "Expression has spaces" } else { write-host "Expression has no spaces" } $var2 if (($regex.IsMatch($var2)) -eq "False") { write-host "Expression has spaces" } else { write-host "Expression has no spaces" }