如何找到3个或更多连续字符? [英] How to find 3 or more consecutive characters?
本文介绍了如何找到3个或更多连续字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在检查密码.这些功能之一是查找是否连续重复输入的密码.我还没有代码,因为我不知道该怎么做.
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.
我发现了这一个 RegEx可以匹配两个或多个相同字符非连续,但只能匹配重复的逗号.
I found this one RegEx match two or more same character non-consecutive but it only match repeated commas.
以下是场景:
5236aaa121-重复模式,因为a
连续重复3次
5236aaa121 - Repeated pattern because a
is consecutively repeated 3 times
2312aa32aa-无重复字符
2312aa32aa - No repeated character
111111asd-重复模式,因为1
被连续多次重复
111111asd - Repeated pattern because 1
is consecutively repeated many times
推荐答案
使用向后引用:/(.)\1\1/
示例:
var hasTripple = /(.)\1\1/.test('xyzzzy');
这篇关于如何找到3个或更多连续字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文