【发布时间】:2015-03-12 01:26:45
【问题描述】:
我有一个包含字符串的列表列表。经过各种正则表达式的工作后,我已将我想用作分隔符的 @@@ 插入到我的字符串中:
[['@@@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']]
到目前为止,我的尝试都是臃肿、笨拙且丑陋的。我发现自己分裂、组合和匹配。任何人都可以就此类问题推荐一些一般性建议,以及使用哪些工具来使其易于管理?
编辑请注意! and heres more 在理想输出中确实出现了两次!
【问题讨论】:
-
您能否阐明有关何时应在输出中包含“还有更多”的规则?它应该只出现在输出列表中一次吗?此外,输入列表中嵌入的列表都用逗号分隔?
-
感谢您的提问。可能存在重复的文本...必须保留,并且必须保持顺序。