Fastest and elegant way to check whether some element expressed by regular expression is in a given list.
For example: given a list:
newlist = ['this','thiis','thas','sada']
regex = re.compile('th.s')
In this question: Regular Expressions: Search in list
list(filter(regex.match,newlist))
give me a list
['this','thas']
However, I just want to return True or False. Therefore above method is not efficient since it looks through all element of newlist. Is there a way like
'this' in newlist
to efficiently and elegantly check whether some element expressed by regular expression is in a given list.