Get Full Matches
Sat 17 May 2025
title: "Get Full Matches" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false
import re
from typing import List
_RGX = re.compile(r'(.)\1*')
def long_repeat(string: str) -> List[str]:
return [m.group(0) for m in _RGX.finditer(string)]
print(long_repeat('devvvvveeeeeeeeeeeloooooooooper'))
['d', 'e', 'vvvvv', 'eeeeeeeeeee', 'l', 'ooooooooo', 'p', 'e', 'r']
print(long_repeat('country'))
['c', 'o', 'u', 'n', 't', 'r', 'y']
# to do:
# Ignore single characters
Score: 5
Category: regex