Author Posts

April 16, 2016 at 2:52 am

Hi All,

I was trying to match multiple strings by using below code
$logfile = @"
"@ -split "`n"

$logfile -notmatch 'String1' , 'String2',....
it is not working for me
but when i selecting only one string it is working
$logfile -notmatch 'String1'

Please help...

April 16, 2016 at 3:17 am

The -match operator doesn't work that way. However, you can make a regular expression that does multiple patterns with its or operator (the pipe symbol). For example:

$logfile -notmatch 'String1|String2'