module re - \Q\E equivalent

John J. Lee jjl at pobox.com
Sun May 11 17:24:25 EDT 2003


Martin Richtarsky <ai3 at codefactory.de> writes:

> In Perl, you can do m|\Qsomestring\E| to turn off metacharacter
> interpretation temporarily and match given string as is. Is this
> possible with re? I haven't found any metacharacters or flags that
> allow this.

your_re = re.compile(r"blah" + re.escape(somestring) + r"rhubarb")

I suppose.


John




More information about the Python-list mailing list