python regex: variable length of positive lookbehind assertion

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Thu Jun 16 01:39:23 EDT 2016


Michael Torrie writes:

> On 06/15/2016 08:57 AM, Jussi Piitulainen wrote:
>> Marko Rauhamaa writes:
>>> And nothing in alister's answer suggests that.
>> 
>> Now *I'm* surprised.
>
> He simply said, here's a regex that can parse the example string the OP
> gave us (which maybe looked a bit like HTML, but like you say, may not
> be), but don't try to use this method to parse actual HTML because it
> won't work reliably.

Interesting how differently we can read alister's answer. It was only
two sentences, one of which Marko replaced with "[...]" before adding
his own one-liner that is still quoted above. Let me quote alister's
response in full here, the way I see it in Gnus:

# don't try to use regex to parse html it wont work reliably
# i am surprised no one has mentioned beautifulsoup yet, which is probably 
# what you require.

That followed the fully quoted original message, and then there was an
attributed citation from a Bengamin Disraeli, separated as a .sig.

Where in alister's original response do you see a regex that can parse
OP's example? I don't see any regex there. (The text where you seem to
me to say that there is one is still quoted above in the normal way.)

Instead of giving any direct answer to the question, alister expresses
surprise at nobody having suggested an HTML parser. (Marko snipped that,
but I've quoted alister's response in full above, so you can check it
without looking up the original messages.)

A surprise calls for an explanation. Or should I say that I felt that
this particular expression of surprise seemed to me to call for an
explanation, or in the very least that an explanation would not do much
harm and might even be considered mildly interesting. And I saw a fully
adequate explanation: that the question was not about parsing HTML. So I
said so.



More information about the Python-list mailing list