<div dir="ltr"><p>Ok, after sending my post, I see, that the code got a bit screewed up, but morover, there should probably be a word boundary in the closing part of the regexp. A next attempt + added stripping the "yes" delimiter and the whitespace...:</p>
<p>>>> import re<br>>>> input_text = """yes text1 yes text2 yes text3 no text4 yes text5+more Text yes text6  no text7 yes text8 no text9"""<br>>>> yes_parts = re.findall(r"(?s)\byes\b.*?(?=\byes\b|\bno\b|$)", input_text)<br>
>>> yes_parts_infos = [item[3:].strip() for item in yes_parts]<br>>>> yes_parts<br>['yes text1 ', 'yes text2 ', 'yes text3 ', 'yes text5+more Text ', 'yes text6  ', 'yes text8 ']<br>
>>> yes_parts_infos<br>['text1', 'text2', 'text3', 'text5+more Text', 'text6', 'text8']<br>>>> <br><br>HTH,<br></p><p>  Vlasta</p></div>