5

Is there a more 'powershelly' way of matching a single string against an array/collection of regexes other than iterating through each one in turn?

What I'd really like to be able to do is something this

$database.Name -match $includeRegexArray

Given the way Powershell works it feels like there should be a nicer solution than writing a function to iterate over the array

1 Answer 1

5

Select-String will accept an array of regex patterns:

Select-String $includeRegexArray -inp $database.Name
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! I was sure there was a nicer way of doing it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.