convert a string to a regex?
clp2 at rebertia.com
Thu Nov 19 04:06:04 CET 2009
On Wed, Nov 18, 2009 at 6:51 PM, Peng Yu <pengyu.ut at gmail.com> wrote:
> There are many special characters listed on
> I'm wondering if there is a convenient function that can readily
> convert a string with the special characters to its corresponding
> regex. For example,
> "some.thing" => "some\.thing"
If you'd taken 45 seconds to scan the documentation:
Return string with all non-alphanumerics backslashed; this is
useful if you want to match an arbitrary literal string that may have
regular expression metacharacters in it.
More information about the Python-list