SoFunction
Updated on 2025-04-06

A regular expression for matching duplicate characters

A few days ago, I did email address filtering and asked to delete the email address that was repeated several times in succession. I tried many times before I tried this regular expression.

/([a-z0-9A-Z])\1{2,}/ Match 3 or more duplicate characters, such as aaaa,bbb,cccc,000

/[a-z0-9A-Z]{3,}/ Match 3 or more characters, such as abc, ab34