Regex to remove duplicate letters but not numbers -
what appropriate regex remove adjacent duplicate letters not numbers?
for example:
p11ppppl --> p11pl i had following regex:
/[^\w\s]|(.)(?=\1)/g but replaces duplicate numbers.
i (visualized here):
/([a-za-z])(?=\1)/g here's example in python:
in [21]: re.sub(r'([a-za-z])(?=\1)', '', 'p11ppppl') out[21]: 'p11pl' you use:
/([\d])(?=\1)/g for except digits, or:
/([\w])(?=\1)/g for "word characters".
as @casimir et hippolyte mentioned in comments, can use:
/([a-za-z])\1+/g with \1 replacement string, may better approach.