Python: Elegant way to check if at least one regex in list matches a string -


I have a list of regexes in Python, and a string. Is it a great way to see if there is at least one raggext string in the list? Elegantly, I mean it is better to stop looping through all reggaxos and to check them against the string and stop getting a match.

Actually, I had this code:

  list = ['some', 'other', 'object', 'hello'] string = 'high' In the list string: Pass # Something else: Pass # Something else  

Now I just want to make some regular expressions in the list instead of stars, and I wonder if the To change the match is a great solution to check if the string in the list: .

Thanks in advance. Regexes = ["Foo. *", "Bar. *", "

  Qu * x "] # Make a regex that matches any of our regexes matches. "Regexes +" if re.match (combined, mismatched): print "some regex matching!"  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -