- 匹配邻近的【】
let str="未查询到邮箱【zhangsan@163.cn】的用户信息【ccc】【中的】";
let reg1=/【([\u4e00-\u9fa5]*|\w*@\w*.\w*|\w*)】/g; //全部匹配
str.match(reg1); // ["【zhangsan@163.cn】", "【ccc】", "【中的】"]
let reg2=/【([\u4e00-\u9fa5]*)】/g; //只匹配中文
str.match(reg2); // ["【中的】"]
let reg3=/【(\w*@\w*.\w*)】/g; //匹配邮箱,不是很严谨
// 邮箱匹配可参考 ^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$
str.match(reg3); // ["【zhangsan@163.cn】"]
let reg4=/【(\w*)】/g;
str.match(reg4); //["【ccc】"]
- 匹配最外层
let str="未查询到邮箱【zhangsan@163.cn】的用户信息【ccc】【中的】";
let reg1=/【/S*】/g; //全部匹配
str.match(reg1); // ["【zhangsan@163.cn】的用户信息【ccc】【中的】"]