Commit fd811d46 by 蒋勇

d

parent f428e0fd
// var http = require('http');
// var server = http.createServer((req,res) => {
// //设置 HTTP 头部,状态码是 200,文件类型是 html,字符集是 utf-8
// res.writeHead(200,{"Content-Type":"text/html;charset='utf-8'"});
// res.write('<h1>Node.js</h1>');
// res.end('Hello World\\n');
// })
// server.listen(3000);//监听端口号是3000的服务器
// console.log("end");
// var str="sdfd_xxx";
// var ind=str.lastIndexOf("_");
// if(ind>=0){
// var st2=str.substring(ind+1);
// if(st2=="N"){
// var st1=str.substring(0,ind);
// console.log(st1);
// }else{
// console.log(str);
// }
// }
function getMonth(type,text){
var qs=["一","二","三","四"];
var qmap={
"一":"03","二":"06","三":"09","四":"12"
};
//ITQ
if(type=="ITQ" || type=="ST" || type=="GT"){
var p1=/\d{4}[-|-]\d{2}[-|-]\d{2}/gm;
var ms=text.match(p1);
var lstDate=ms[1];
var ds=lstDate.split("-");
var rtnDate=ds[0]+ds[1];
return rtnDate;
}else{
var testbool=false;
var p2=/(\d{4})|([一|二|三|四])/gm;
var ms=text.match(p2);
console.log(ms);
for(var q of qs){
var jstr=ms.join(",");
var re = new RegExp(q);
if(re.test(jstr)){
console.log("======");
testbool=true;
break;
}
}
if(!testbool){//如果不是季
var p3=/\d{4}[-|-]\d{2}/gm;
var ms=text.match(p3);
return ms[0].split("-").join("");
}else{//如果是季
var qstr=ms[1];
var rtndate=ms[0]+qmap[qstr];
return rtndate;
}
}
}
// var text=`日期:2019-11(请按照此日期格式填写日期,否则系统无法识别)`;
// var g=getMonth("dd",text);
// console.log(g);
// return;
// //ITQ
// var text=`税款所属期间:2019-06-01至2019-09-30
// 请按照此日期格式填写日期,否则系统无法识别)`;
// var g=getMonth("ITQ",text);
// console.log(g);
// //ST
// text="税款所属期:2019-06-01至2019-09-30(请按照此日期格式填写日期,否则系统无法识别)";
// var g=getMonth("ST",text);
// console.log(g);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment