May-14-2024, 12:29 PM
(May-14-2024, 08:14 AM)Gribouillis Wrote: This perhapsThank you, this solution does work but there is a compilation error stating that groups are not supported in lookbehinds. Any way to clear that up. Appreciate it.
>>> import re >>> p = re.compile(r'(\w)(?<!\1\1)\1\1(?!\1)') >>> >>> [m.group() for m in p.finditer('ab999thc7')] ['999'] >>> [m.group() for m in p.finditer('abddddthc7')] [] >>> [m.group() for m in p.finditer("AAAbbcDDDEDGGGG")] ['AAA', 'DDD']