Python: re..find longest sequence

后端 未结 5 645
清歌不尽
清歌不尽 2021-01-06 07:28

I have a string that is randomly generated:

polymer_str = \"diol diNCO diamine diNCO diamine diNCO diamine diNCO diol diNCO diamine\"

I\'d

5条回答
  •  太阳男子
    2021-01-06 08:10

    I think the op wants the longest contiguous sequence. You can get all contiguous sequences like: seqs = re.findall("(?:diNCO diamine)+", polymer_str)

    and then find the longest.

提交回复
热议问题