标签:
代码:
1 /** 2 * Created by Administrator on 2016/8/12. 3 */ 4 (function () { 5 6 var url = "http//baidu.com#a=你好&b=world"; 7 var url1 = "http//baidu.com#a=dd&b=world"; 8 var p = /[#&\?]([^=]+)=([^&]+)/g; 9 var p1=/\w+=\w+/g; 10 var obj={}; 11 while (true){ 12 var result=p.exec(url); 13 var result1=p1.exec(url); 14 if(result){ 15 obj[result[1]]=result[2]; 16 console.log(obj); 17 }else { 18 break; 19 } 20 } 21 })();
挺实用的一个小例子。好的,又一块砖放好了O(∩_∩)O
标签:
原文地址:http://www.cnblogs.com/chenluomenggongzi/p/5777564.html