I'm making a password checking. One of those functions is to find if the inputted password is consecutively repeated. I do not have codes yet because I don't know how to do it.
I found this one RegEx match two or more same character non-consecutive but it only match repeated commas.
Here's are the scenarios:
5236aaa121 - Repeated pattern because a
is consecutively repeated 3 times
2312aa32aa - No repeated character
111111asd - Repeated pattern because 1
is consecutively repeated many times
Get the String. Create a regular expression to check 3 or more consecutive identical characters or numbers as mentioned below: \\b represents the word boundary. ( represents the starting of the group 1. [a-zA-Z0-9] represents a letter or a digit.
3 or more consecutive sequential characters/numbers; e.g. 123, abc, 789, pqr, etc. 3 or more consecutive identical characters/numbers; e.g. 111, aaa, bbb, 222, etc.
3 or more consecutive identical characters/numbers; e.g. 111, aaa, bbb, 222, etc. Show activity on this post. For case #2 I got inspired by a sample on regextester and created the following regex to match n identical digits (to check for both numbers and letters replace 0-9 with A-Za-z0-9 ):
Not possible with regular expressions. 3 or more consecutive identical characters/numbers ex - 111, aaa, bbb. 222 etc. Use a pattern of (?i) (?: ( [a-z0-9])\1 {2,})*.
Use a back reference: /(.)\1\1/
Example:
var hasTripple = /(.)\1\1/.test('xyzzzy');
JSFiddle Example
Try this regex: (.)\1\1+
/(.)\1\1+/g
The dot matches any character, then we are looking for more than one in a row. i tested it on http://regexpal.com/ and i believe it does what you want
you can use this like this:
str.match(/(.)\1\1+/g).length
just check that it is 0
to see this in action.... http://jsfiddle.net/yentc/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With