lets say i have a string s = something1something2somethings1somethings2somethings3
i'm looking for a pattern = '<.?>', my string has 2 types of pattern, '<.?>' and '<.*?>' and i want to list all the substrings matching the first pattern when i use findall or finditer, what i get is and somethings1somethings2
But what i want to get is or ideally, head1, head3
My code below,
s = something1something2somethings1somethings2somethings3 result = re.finditer('<.?>', s) or print re.findall('<.?>', s)
Thanks in advance for your help!
Aucun commentaire:
Enregistrer un commentaire