what is wrong with that r"\"
nick at craig-wood.com
Thu Jul 5 10:30:03 CEST 2007
Marc 'BlackJack' Rintsch <bj_666 at gmx.net> wrote:
> On Wed, 04 Jul 2007 11:21:14 +0000, Neil Cerutti wrote:
> > If the escaped quotes didn't function in raw strings, I'd be
> > unable to construct (with a single notation) a regex that
> > included both kinds of quotes at once.
> > re.compile(r"'\"")
> Where's the problem!? ::
> Ah, I see -- readability is the problem. :-)
Actually the problem is that those backslashes don't actually
disappear thus producing non-intuititive behaviour. The example you
provided produces a different result to Neil's result.
Neil is correct in saying that his example works for regexp matching
though, as the regexp matcher understands \" as being the same as ".
So r"" strings work well as Regexp-strings but not so well as
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list