Popular recipes by mark williamson http://code.activestate.com/recipes/users/1219787/2005-10-31T04:54:30-08:00ActiveState Code RecipesPattern List (Python)
2005-10-31T04:54:30-08:00mark williamsonhttp://code.activestate.com/recipes/users/1219787/http://code.activestate.com/recipes/442497-pattern-list/
<p style="color: grey">
Python
recipe 442497
by <a href="/recipes/users/1219787/">mark williamson</a>
(<a href="/recipes/tags/search/">search</a>).
</p>
<p>I found my self want to express -string- in -list of regular expressions- and so I wrote this quick object to do the trick for me. It takes a list of strings containing regular expressions, compiles them into an internal list and then using the __contains__ operation ("in") looks to see if a given string contains any of the expressions. The first success returns True otherwise it returns False.</p>