Check the URL
let str = "https://www.baidu.com/s?wd=%E6%8E%98%E9%87%91&rsv_spt=1&E%2598%25E9%2587%2591&rsp=0";
let reg = / ^ (? :(http|https|ftp):\/\/)? ((? :[\w-]+\.) +[a-z0-9]+)((? : \ [# ^ /?] / *) +)? (\? [^ #] +)? (#. +)? $/i;
console.log(reg.exec(str));
Copy the code
URL format
- 1. The agreement:
/ ^ (? :(http|https|ftp):\/\/)?
- 2. The domain name:
((? :[\w-]+\.) +[a-z0-9]+)
- / /index.html /stu/index.html /stu
((? : \ [# ^ /?] / *) +)?
- 4. Question mark reference? xxx=xxx&xxx=xxx
(\? [^ #] +)?
- 5. Hash # XXX
(#. +)? $/i;
Check the password
The password contains 6 to 16 uppercase and lowercase letters and digits
let reg = / (? ! ^[a-zA-Z]+$)(? ! ^[A-Z0-9]+$)(? ! ^ / a - z0-9 + $) ^ [a zA - z0-9] 6 16th} {$/;
Copy the code