I have the string, containing numbers(0~9), characters(A~Z) and brackets("()"). and if containing brackets, must treat the brackets and the number(or the character) as together. For example, "(G)8(8)(G)4(C)(G)8(8)" or "(2)2(6)2(6)2(2)2(8)". And then I need to find the pattern in this string(not overlapping). Here, the string, I mean it occurs twice or more. Take
"(2)2(6)2(6)2(2)2(8)"
for example, the pattern I want to extract is
"2(6)", "(2)2" and "(6)2"
, because they occur twice. and the string
"(G)8(8)(G)4(C)(G)8(8)"
, I can extract
"(G)8(8)"
. I know re.findall(r'\bv\w+', string), this function can find the pattern, but it can't apply to my situation. Can anyone help me? Thank you.
Aucun commentaire:
Enregistrer un commentaire