I need a RegEx to trigger a validation message when a user enters 2 repeating characters.
Asked
Active
Viewed 667 times
1 Answers
4
Well
var repeats = /(.)\1/;
will match any string with a character repeated in it.
Thus
if (repeats.test("hello")) alert("true because of the two 'l' characters");
and
if (!repeats.test("frederick the great")) alert("test fails because no characters repeat");

Pointy
- 405,095
- 59
- 585
- 614