python regex: variable length of positive lookbehind assertion

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Wed Jun 15 10:57:09 EDT 2016


Marko Rauhamaa writes:

> Jussi Piitulainen writes:
>
>> alister writes:
>>
>>> On Tue, 14 Jun 2016 20:28:24 -0700, Yubin Ruan wrote:
>>>> Given a string like this:
>>>> 
>>>>     >>>string = "false_head <a>aaa</a> <a>bbb</a> false_tail \
>>>>              true_head some_text_here <a>ccc</a> <a>ddd</a> <a>eee</a>
>>>>              true_tail"
>>>>
>>>> I want to match the all the text surrounded by those "<a> </a>",
>>>> [...]
>>>
>>> don't try to use regex to parse html it wont work reliably
>>> [...]
>>
>> Nothing in the question indicates that the data is HTML.
>
> And nothing in alister's answer suggests that.

Now *I'm* surprised.



More information about the Python-list mailing list