user391986
user391986

Reputation: 30906

validating an array of regex string on a string

I have an array of regex to apply on a string.

regexString = "'\d{2,}';'..'"
regexPatterns = regexString.split(";")
regexPatterns = ["'\d{2,}'","'..'"]

How can I efficiently use that list and only match if all the regex find a match?

Upvotes: 0

Views: 109

Answers (1)

sth
sth

Reputation: 229603

You could use the built-in all() function:

isgood = all(re.search(regex, s) for regex in regexPatterns)

Upvotes: 3

Related Questions