用正则表示式,取中文中所有中括号[]的内容

let testStr = "now [里斯本] [test002] [ddddd] [adfasd][3234]"; function getFaceTag(message) { let re = /\[([\u4e00-\u9fa5\w]+)\]/g; let r = {fulltag:[],tags:[]}; let m; while(m = re.exec(message)) { r.fulltag.push(m[0]); r.tags.push(m[1]); } return r;}let k = getFaceTag(testStr);console.log(k);








转自 https://blog.csdn.net/zdhsoft/article/details/70209362

猜你喜欢

转载自blog.csdn.net/qq_41813695/article/details/81047920