[Py007]|[Py007] re匹配字符串整体

【[Py007]|[Py007] re匹配字符串整体】对某个字符串重复m到n次来进行匹配

In[59]: list Out[59]: 'mRNA; lncRNA; mRNA; exon; exon; lncRNA; mRNA; exon; exon; exon; mRNA; exon; mRNA; exon; exon; exon; exon; exon; exon; ' In[60]: re.findall(r'mRNA; (?:exon; ){2,4}',list) Out[60]: ['mRNA; exon; exon; ', 'mRNA; exon; exon; exon; ', 'mRNA; exon; exon; exon; exon; ']

(?:string)可以将string看成一个整体

    推荐阅读