I need to search by string to see if it contains any text in an array of strings. for instance
excludeList = "warning", "general unimportant thing", "something else"
searchString = here is a line telling us about a common non-essential thing.
otherString = something common but not related
In this example, we will find the string "common non-essential thing" from the array in my searchList and return true. however, otherString does not contain any of the complete lines in the array, therefore returns false.
I am sure it is not so difficult, but I have looked at it for too long ...
Update: The best I can do so far:
$arrColors = "blue", "red", "green", "yellow", "white", "pink", "orange", "turquoise"
$testString = "there is a blue cow over there"
$test2="blue"
$count=0
$arrColors | ForEach-Object{
echo $count
echo $testString.Contains($arrColors[$count])
$count++
}
he is not too elegant, though ...
source
share