Open harttle opened 6 years ago
分析的比较细,学习了。
By hieast 2016-06-20T05:55:40Z
同志你打错一个词
var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
var url = "http://harttle.com:80/tags.html?simple=true#HTML",
result = parse_url.exec(url);
blanks = ' ';
fields = ['url', 'scheme', 'slash', 'host', 'port', 'path', 'query', 'hash'];
fields.forEach(function(filed, i){
console.log(field + ':' + blanks.substr(field.length) + result[i]);
});
fields.forEach(function(field)) 这里应该是field才对~
By Scar Qin 2017-09-12T11:08:53Z
😀多谢指出
By Yang Jun 2017-09-13T02:10:23Z
写得很好~
By Scar Qin 2017-09-13T03:17:19Z
用正则表达式分析 URL - Harttle Land
http://harttle.land/2016/02/23/javascript-regular-expressions.html