分组
分组字符集
分组模式
普通捕获组
/([\d]{4})-([\d]{2})-([\d]{2})/.exec("2019-07-02"); // 捕获年月日
/**
匹配结果数组:["2019-07-02", "2019", "07", "02", index: 0, input: "2019-07-02", groups: undefined]
数据[0]:完整匹配字符串
数组[1]:捕获“年”
数组[2]:捕获“月”
数组[3]:捕获“日”
**/

嵌套捕获组


命名捕获组

非捕获组


Last updated
Was this helpful?