We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
/#([0-9a-zA-Z]{3}|[0-9a-zA-Z]{6})/
^(((0|1)\d)|2[0-3]):[0-5]\d$
如果前面的0可以省略 结果为:
^(0?\d|1\d|2[0-3]):(0?\d|[1-5]\d)$
/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/
对于2018-01-05兼容简写形式18-1-5
/^(\d{4}|\d{2})-(0?[1-9]|1[0-2])-(0?[1-9]|[12]\d|3[01])$/
/^[a-zA-Z]:\\([^\n\r?:\\/*"<>|]+\\)*[^\n\r?:\\/*"<>|]*$/
/id=".*"/ //output:'id="container" class="main"'
原因:*量词默认是贪婪匹配,所以增加?变为惰性匹配
/id=".*?"/ //output:'id="container"'
/.^/或者/$./
/(?!^)(?=(\d{3})+$)/g output:'123,456,789'
匹配'1234 5678 912 345 6789'
/(?!\b)(?=(\d{3})+\b)/g output: '1,234 5,678 912 345 6,789'
(?!\b) = \B 所以可以变换为
/\B(?=(\d{3})+\b)/g
var num = 1880 var reg1 = /(?!^)(?=(\d{3})+$)/g var reg2 = /^/ num.toFixed(2).replace(reg1,',').replace(reg2,'$ ') // output:$ 1,880.00
/^[0-9A-Za-z]{6,12}$/
/(?=.*[0-9])^[0-9A-Za-z]{6,12}$/
/((?=.*[0-9])(?=.*[a-z])|(?=.*[A-Z])(?=.*[a-z])|(?=.*[0-9])(?=.*[A-Z]))^[0-9A-Za-z]{6,12}$/
方法2: /(?!^[0-9]{6,12}$)(?!^[a-z]{6,12}$)(?!^[A-Z]{6,12}$)^[0-9A-Za-z]{6,12}$/
/(?!^[0-9]{6,12}$)(?!^[a-z]{6,12}$)(?!^[A-Z]{6,12}$)^[0-9A-Za-z]{6,12}$/
/^\s+|\s+$/g
或者
/^\s*(.*?)\s*$/g
这里使用?惰性匹配防止匹配到最后一个空字符串之前的空字符串 11. 每个单词的首字母替换为大写
/(?:^|\s)\w/g
这里也可以不使用非捕获 12. 驼峰法
/[\s_-]+(.)?/g
var str = '<span>lulin</span>' var reg = /<([^]+)>[\d\D]*<\/\1>/
/^(\d{15}|\d{17}[\dxX])$/
/^((0{0,2}\d|0?\d{2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(0{0,2}\d|0?\d{2}|1\d{2}|2[0-4]\d|25[0-5])$/
The text was updated successfully, but these errors were encountered:
No branches or pull requests
#ffbbad
#Fc01DF
#FFF
#ffE
结果为:
23:59
02:07
结果为:
如果前面的0可以省略
结果为:
2018-12-25
对于2018-01-05兼容简写形式18-1-5
"F:\study\javascript\regex\regular expression.pdf"
"F:\study\javascript\regex\"
"F:\study\javascript"
"F:\"
''
原因:*量词默认是贪婪匹配,所以增加?变为惰性匹配
匹配'123456789'
匹配'1234 5678 912 345 6789'
(?!\b) = \B 所以可以变换为
密码长度6-12位,由数字、小写字母、大写字母组成,但必须至少包含2种字符
方法1:
step1:匹配数字、小写字母、大写字母
/^[0-9A-Za-z]{6,12}$/
step2:必须包含数字
/(?=.*[0-9])^[0-9A-Za-z]{6,12}$/
step3:必须包含任意两种
/((?=.*[0-9])(?=.*[a-z])|(?=.*[A-Z])(?=.*[a-z])|(?=.*[0-9])(?=.*[A-Z]))^[0-9A-Za-z]{6,12}$/
方法2:
/(?!^[0-9]{6,12}$)(?!^[a-z]{6,12}$)(?!^[A-Z]{6,12}$)^[0-9A-Za-z]{6,12}$/
或者
这里使用?惰性匹配防止匹配到最后一个空字符串之前的空字符串
11. 每个单词的首字母替换为大写
这里也可以不使用非捕获
12. 驼峰法
The text was updated successfully, but these errors were encountered: