1 <!-- * 示例:2016027马红旗2 2 * 处理结果:2016027-马红旗2 --> 3 <html lang="en"> 4 5 <head> 6 <meta charset="UTF-8"> 7 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 8 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 9 <title>Document</title> 10 <script type="text/javascript"> 11 12 var str = "2016闫佳027闫佳1雪89080闫杰980马红旗2"; 13 var re1 = /(\d{1,3})+(?:\.\d+)?/g 14 var re2 = /[\u4e00-\u9fa5]{2,}/g 15 16 console.log('初始:',str); 17 18 var arr1 = str.match(re1); 19 var arr2 = str.match(re2); 20 21 console.log('arr1',arr1); 22 console.log('arr2',arr2); 23 24 console.log('结果:',arr1[0]+"-"+arr2+"-"+arr1[1]); 25 </script> 26 </head> 27 28 <body> 29 30 </body> 31 32 </html>
标签:console,拆分,str,前端,var,arr2,arr1,字符串,log From: https://www.cnblogs.com/stary-pointer/p/17153736.html