var str = "117.39755436808615, 34.59211450864094;117.39783481906638, 34.59185738594207;117.39825396841732, 34.59151467824745;117.39895365857903, 34.59099990825333;117.39975863014654, 34.59003217058297;117.40108929009845, 34.58869213304237;" var newArr = [] var reg = /([^,;;]+)[,\s]+([^,;;]*)/g; while(reg.exec(str)){ console.log( RegExp.$1 + "," + RegExp.$2); var aa = [Number(RegExp.$1),Number(RegExp.$2)] newArr.push(aa) } console.log('aaa==>>',newArr)
结果展示
一般是在地图的时候用到的
标签:aa,console,分号,newArr,Number,js,逗号,var,RegExp From: https://www.cnblogs.com/menxiaojin/p/16839291.html