convert a string to a regex?

Peng Yu pengyu.ut at gmail.com
Wed Nov 18 22:27:58 EST 2009


On Wed, Nov 18, 2009 at 9:12 PM, Tim Chase
<python.list at tim.thechases.com> wrote:
>> There are many special characters listed on
>> http://docs.python.org/library/re.html
>>
>> 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"
>
> Did you try bothering to *read* the page you linked to?
>
> There's a function for escaping strings right there...
>
> Literacy...a worthwhile skill to obtain.

Sorry, I didn't see it. If there are examples besides explanations for
each command, it will help people see the usage of each command more
easily.



More information about the Python-list mailing list