passing multiple strings to string.find()

Fredrik Lundh fredrik at pythonware.com
Fri Aug 8 09:35:44 EDT 2003


Francois Pinard wrote:

> Given the above,
>
>
>    build_regexp(['this', 'that', 'the-other'])
>
>
> yields the string 'th(?:is|at|e\\-other)', which one may choose to
> `re.compile' before use.

footnote: the SRE compiler looks for common prefixes, so "th(?:is|at|e\\-other)"
is no different from "this|that|the-other" on the engine level.

</F>








More information about the Python-list mailing list