"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
| >>> def spam2(x, s=re.compile('nobody expects the Spanish 
Inquisition!')):
| ...     return s.search(x)
|
| I suspect that this will be not only the fastest solution, but also the
| most flexible.

'Most flexible' in a different way is

def searcher(rex):
    crex = re.compile(rex)
    def _(txt):
        return crex.search(txt)
    return _

One can then create and keep around multiple searchers based on different 
patterns, to be used as needed.

tjr



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to