python regex: variable length of positive lookbehind assertion
ablacktshirt at gmail.com
Tue Jun 14 23:28:24 EDT 2016
I am struggling writing a right regex that match what I want:
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>",
but only if those "<a> </a>" locate **in some distance** behind "true_head". That is, I expect to result to be like this:
>>>result = re.findall("the_regex",string)
How can I write a regex to match that?
I have try to use the **positive lookbehind assertion** in python regex,
but it does not allowed variable length of lookbehind.
Thanks in advance,
More information about the Python-list