var fullTime = "2020-12-11到2021-12-12"; // 日期字符串 var timeArr1 = fullTime.split(/[-到]/); var cynian = timeArr1[0]; var cyyue = timeArr1[1]; var cyri = timeArr1[2]; var cynian=timeArr1[3]; var cyyue=timeArr1[4]; var cyri=timeArr1[5]; var time1 =nian+'-'+yue+'-'+ri; var time2 =x+'-'+y+'-'+z; var mystring = "jb51.net,google.com,baidu.com_weibo.com_haotu.net"; var myarray = mystring.split(/[,_]/); console.log(myarray)