Re: convert a string to a regex?
Peng Yu schrieb: On Wed, Nov 18, 2009 at 9:12 PM, Tim Chase python.l...@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. Or it will clutter the whole page. That's not to say the docs can't be improved. But *reading* them will always be required. Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: convert a string to a regex?
On Wed, Nov 18, 2009 at 6:51 PM, Peng Yu pengyu...@gmail.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 If you'd taken 45 seconds to scan the documentation: http://docs.python.org/library/re.html#re.escape re.escape(string) 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. Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list
Re: convert a string to a regex?
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. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: convert a string to a regex?
On Wed, Nov 18, 2009 at 9:12 PM, Tim Chase python.l...@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. -- http://mail.python.org/mailman/listinfo/python-list