//格式化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);
});
}