标签:style blog color cti for io
//格式化url查询参数为json function formatUrl(url){ var reg=/(?:[?&]+)([^&]+)=([^&]+)/g; var data={}; function fn(str,pro,value){ data[decodeURIComponent(pro)]=decodeURIComponent(value); } url.replace(reg,fn); return data; }
//替换索引编号 function replaceIndex(str){ var regExp = new RegExp(‘<%=(.*?)%>‘); var replaceText = Math.floor(Math.random()*100000000); var i = str.search(‘<%=(.*?)%>‘); var n = str.search(regExp); console.log(‘i ‘, i, n, typeof str); var newstr = str.replace(regExp,replaceText); //console.log( newstr ); fs.writeFile(path, newstr, ‘utf-8‘, function(err){ console.log(‘backfill error‘,err); }); }
标签:style blog color cti for io
原文地址:http://www.cnblogs.com/didi/p/3812270.html