在Python中基于分隔符拆分和组合文本

在Python中基于分隔符拆分和组合文本,python,string,list,text,Python,String,List,Text,我有一个列表,包含字符串。在各种各样的正则表达式工作之后,我将要用作分隔符的内容插入字符串中,@@@: [['@@@this is part one and here is part two and here is part three and heres more and heres more'], ['this is part one@@@and here is part two and here is part three and heres more and heres more'],

我有一个列表,包含字符串。在各种各样的正则表达式工作之后,我将要用作分隔符的内容插入字符串中,
@@@

[['@@@this is part one and here is part two and here is part three and heres more and heres more'],
 ['this is part one@@@and here is part two and here is part three and heres more and heres more'],
 ['this is part one and here is part two@@@and here is part three and heres more and heres more']
 ['this is part one and here is part two and here is part three@@@and heres more and heres more']
 ['this is part one and here is part two and here is part three and heres more@@@and heres more']]
现在,我需要想出一个办法:

[['this is part one'],['and here is part two'],['and here is part three'], ['and heres more'], ['and heres more']]  
到目前为止,我的尝试都是浮夸的、粗糙的,而且总体上是丑陋的。我发现自己在分裂、合并和匹配。有谁能推荐一些关于这类问题的一般性建议,以及使用什么工具来保持它的可控性


编辑请注意
还有更多
确实在理想输出中出现了两次

我认为您实际上需要抓取紧跟在
@@@@code>之后的所有字符,直到下一个
或字符串结尾

>>> [[m] for x in l for m in re.findall(r'@@@(.*?)(?=\sand\b|$)', x[0])]
[['this is part one'], ['and here is part two'], ['and here is part three'], ['and heres more'], ['and heres more']]

看起来现在文本失去了它的顺序:第一部分不再是第一部分了!set()不保留顺序@MattO'Brien你是说更新吗?。。您是希望上述预期输出用于整个列表还是仅用于第一个内部列表?@MattO'Brien您能用准确的预期输出更新您的问题吗?该问题具有正确的预期输出…事实上,
,这里还有更多的
必须出现两次!你能澄清一下什么时候“还有更多”应该包含在输出中吗?它应该只在输出列表中出现一次吗?此外,输入列表中嵌入的列表都用逗号分隔?谢谢你的提问。可能有重复的文本…必须保留,并且必须保持秩序。