7、判断输入的是正确的网址
- 协议:
http://https://ftp://(可省) - 域名:www.xxx.xx xxx.xx xx.xx.xx.xx
- 请求路径
index.htmlstu/index.html/stu(可省) - 问号传参
?xx=xx(可省) - 哈希值
#xxx(可省)
let str = 'http://smileyqp.com/smile'
let reg = /^((http|https|ftp):\/\/)?(([\w-].)+[a-z0-9]+)((\/[^/]*)+)?(\?[^#]+)?(#.+)?$/i;
console.og(reg.exec(str))