请教一下JS高手,下面正则表达式的含义。
window.location.href.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);...
window.location.href.match(/^https?\:\/\/([^\/?#]+)(?:[\/?#]|$)/i);
展开
1个回答
2017-05-25
展开全部
匹配url的
例如:http://www.baidu.com/index.html
^https?\:\/\/ ==== 以http;//开头,或https;//开头,
([^\/?#]+) === 除了/ ? # 这3个字符之外的任意字符,任意多个 即上例中的 www.baidu.com
(?:[\/?#]|$) === 匹配/ ? # 或 字符串结束
例如:http://www.baidu.com/index.html
^https?\:\/\/ ==== 以http;//开头,或https;//开头,
([^\/?#]+) === 除了/ ? # 这3个字符之外的任意字符,任意多个 即上例中的 www.baidu.com
(?:[\/?#]|$) === 匹配/ ? # 或 字符串结束
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询