实例:字符串 capchs/3.png,如何用正则取得 3

1
2
3
4
var path = "capchs/3.png";
var pattern = "capchs/(.*).png";
var r = path.match(pattern);
console.log(r[1]);

MDN 详细文档