-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[js]正则匹配 #7
Comments
提示: \w 是有_ |
@bailnl 只匹配数字字母,不匹配其它符号, |
@VaJoy 我改。 已更新 |
@bailnl 👍good,那我换一种写法 var reg = /([a-zA-Z\d])((?=\1{4})(\1))+/g |
var reg=/([a-z0-9])\1+(?=\1{3})/ig; |
@YoungPigs 不能用 |
var str = 'attttt gggggggggggg 66666bbbb';
var reg = /([a-zA-Z\d])\1+(?=\1{3})/g;
reg.lastIndex = 0;
console.log( str.replace(reg, "") );
//attt ggg 666bbbb |
来一个新特性吧,命名捕获组的处理方法 let result = 'abbbbbeeee12222222223'.replace(/(?<tag>[^\W_])\k<tag>{2,}/g, '$<tag>$<tag>$<tag>')
console.log(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
需求
匹配重复5次以上的字母或数字,删除其剩下最后3位之前的部分
The text was updated successfully, but these errors were encountered: