help with regular expression

Ben Logan ben at
Sat Dec 8 22:24:55 CET 2001

Thanks, that worked.  I did modify it so that the >> can be anywhere
within quotes, not just by themselves.  Next, I'll have to take into
account whether or not the quote is a backslash-escaped one.  I
think I can work through that one, but I'll yell if I can't. ;)


On Sat, Dec 08, 2001 at 12:36:29PM -0600, Jason Orendorff wrote:
> > I am writing a program in which I need to search an arbitrary string
> > and return the part between a certain opening sequence, and a closing
> > sequence.  [...]  I want to be able to "escape" the ending
> > sequence with either double quotes (">>") or single quotes ('>>').
>   r"""<<(('>>'|">>"|>(?!>)|[^>])*)>>"""
> See
> for the meaning of (?!>).

Ben Logan: ben at wblogan dot net
OpenPGP Key KeyID: A1ADD1F0

More information about the Python-list mailing list