0

Is there a simple way to do this type of compare:

$s = {"This is a dog" ,"This is a cat"} $s | where {$_.Phrase -contains -match{"dog",cat","rat"} } 

Basically, if the left contains any part of anything on the right, I want it returned.

Or do I have to do -or for each thing on the right?

1 Answer 1

2

Assuming that $s is an array of strings (and not a scriptblock) you could create the appropriate regular expression for the -match operator and just use that:

# ~> $s = @("This is a dog" ,"This is a cat", "this is neither") # ~> $s | where {$_ -match "dog|cat|rat" } This is a dog This is a cat 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.