//regex
const regex = /^(\w+)\:\/\/([^\/]+)\/(.*)$/;
let url = `https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions`;
regex.test(url);
// true
regex.exec(url);
/*
(4)
[
"https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions",
"https",
"developer.mozilla.org",
"zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions",
{
index: 0,
input: "https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions"
}
]
0:"https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions"
1:"https"
2:"developer.mozilla.org"
3:"zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions"
index:0
input:"https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions"
length:4
*/
https://regexper.com/#%2F%5E(%5Cw%2B)%5C%3A%5C%2F%5C%2F(%5B%5E%5C%2F%5D%2B)%5C%2F(.*)%24%2F
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions#special-capturing-parentheses
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions#special-quantifier
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Guide/Regular_Expressions#special-digit