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
小练习:
\d
\w
\s
[a-zA-Z0-9]
\b
.
*
+
?
x{3}
^
$
\n
function trim(str) { return str.replace(/^\s+|\s+$/g, ''); }
function isEmail(str) { return /^\w+@[a-zA-Z0-9]+\.[a-z]{2,4}$/.test(str); }
function isPhoneNumber(str) { return /^1\d{10}$/.test(str); }
function isValidUsername(str) { return /^\w{6,20}$/.test(str); }
function isValidPassword(str) { if (!/^\w{6,20}$/.test(str)) { return false; } if (/^[A-Z]{6,20}$/.test(str)) { return false; } if (/^[a-z]{6,20}$/.test(str)) { return false; } if (/^[0-9]{6,20}$/.test(str)) { return false; } if (/^_{6,20}$/.test(str)) { return false; } return true; }
var reg = /#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3}(?=;))/g; var subj = "color: #121212; background-color: #AA00ef; width: 12px; bad-colors: f#fddee "; console.log(subj.match(reg)); // ['#121212', '#AA00ef']
var str = 'hello "hunger" , hello "world"'; var pat = /".*"/g; console.log(str.match(pat)); // [ '"hunger" , hello "world"' ] // 贪婪模式下尽量匹配长的字符串 var pat = /".*?"/g; console.log(str.match(pat)); // [ '"hunger"', '"world"' ]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
小练习:
\d
\w
\s
[a-zA-Z0-9]
\b
.
*
+
?
x{3}
^
$
分别是什么?\d
\w
\s
[a-zA-Z0-9]
\b
.
\n
之外的任何单个字符。*
+
?
x{3}
^
$
The text was updated successfully, but these errors were encountered: