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...:
>>> import re >>> input_text = """yes text1 yes text2 yes text3 no text4 yes text5+more Text yes text6 no text7 yes text8 no text9""" >>> yes_parts = re.findall(r"(?s)\byes\b.*?(?=\byes\b|\bno\b|$)", input_text) >>> yes_parts_infos = [item[3:].strip() for item in yes_parts] >>> yes_parts ['yes text1 ', 'yes text2 ', 'yes text3 ', 'yes text5+more Text ', 'yes text6 ', 'yes text8 '] >>> yes_parts_infos ['text1', 'text2', 'text3', 'text5+more Text', 'text6', 'text8'] >>> HTH, Vlasta
-- http://mail.python.org/mailman/listinfo/python-list