-
Notifications
You must be signed in to change notification settings - Fork 0
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
正则表达式 #13
Comments
数字价格千分位分割将123456789变成123,456,789 |
手机号3-4-4分割将手机号18379836654转化为183-7983-6654 |
元字符
|
验证密码的合法性密码长度是6-12位,由数字、小写字母和大写字母组成,但必须至少包括2种字符 console.log(reg.test('123456')) // false
具体讲解可参考:https://juejin.cn/post/6999768570570178596#heading-10 |
提取连续重复的字符将有重复的字符提取出来,例如12323454545666,提取[ '23', '45', '6' ]
|
实现一个trim函数方式1:去除空格法
方式2:提取非空格法
拓展:
|
将字符串驼峰化如下规则,将对应字符串变成驼峰写法
|
将字符串首字母转化为大写,剩下为小写例如 hello world 转为为Hello World
|
匹配日期格式要求匹配(yyyy-mm-dd、yyyy.mm.dd、yyyy/mm/dd),例如2021-08-22、2021.08.22、2021/08/22 可以不考虑平闰年
|
匹配16进制的颜色值
|
检测中文
|
匹配手机号
|
匹配小括号内容
var str = "123{xxxx}(123)456[我的]789123[你的]456(1389090)789";
var regex1 = /((.+?))/g;
//正则表达式里边(.+?)表示匹配:“(”开始,其后至少含有1个除了“)”的任意字符,且再遇到“)”,就结束匹配
console.log(str.match(regex1)); //["(123)", "(1389090)"]
The text was updated successfully, but these errors were encountered: