[thelist] Regular expression for three or more consecutive occurrences of t he same character
Howard Cheng
howcheng at ix.netcom.com
Fri Feb 8 12:33:01 CST 2002
The pattern you're looking for would be:
/(\S)\1\1/
In other words, first match a non-whitespace character and look for it
again two times in a row. To match this n times, you would have to keep
repeating the "\1" part.
/(\S){3}/ doesn't work because this would match three non-whitespace
characters in a row, not necessarily three identical characters in a row.
HTH
At 01:22 PM 2/8/2002 -0500, Ben Gustafson wrote:
>I have a little JavaScript function for checking whether a string has three
>consecutive occurrences of the same character. I'm wondering if there's a
>regular expression for this, one that could be changed to check for n number
>of the same character in a row. How 'bout it, regexp wizards out there?
::::::::::::::::::::::
Howard Cheng
howcheng at ix.netcom.com
AIM: bennyphoebe
ICQ: 47319315
More information about the thelist
mailing list