var path = '/user/tobi'
path.match(/user/);
//result: ["user"]
path.match(/(user)/);
//result: ["user", "user”]
为什么添加“()”会导致两个用户的结果?
最佳答案
String#match
返回由匹配字符串和所有 submatches 组成的数组,由括号中的正则表达式声明。
关于javascript - 正则表达式path.match(/user/);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20137335/