If this is a case-sensitive search, then Split(char[]) will be a concise solution.
$testString="Word"
$illegalCharacter =@{Warning=@("a","b");Error= @("c","d")}
if ($teststring.Split($illegalCharacter.Error).Count -gt 1) {
Write-Host "WORKS!"
}
If you want to use the -match operator or -cmatch (case-sensitive match) operator, you will need to create a regex expression that includes alternations (|).
$testString="Word"
$illegalCharacter =@{Warning=@("a","b");Error= @("c","d")}
$regex = ($illegalcharacter.Error |% { [regex]::Escape($_) }) -join '|'
if ($teststring -match $regex) {
Write-Host "WORKS!"
}
The regex | character performs an OR. In this case, it will attempt to match c and alternatively d if c does not match. Special regex characters need to be escaped if you to match them literally. Regex.Escape(String) escapes regex characters automatically.