var str = 'name[0]'; // 怎样才能取到中括号中的0,只使用一次正则表达式 // 是不是只能这样连着中括号取啊 /\[[\d]+]/.exec(str) // 这样只能取到 [0] //求解..
'name[0]'.match(/\[(.+?)\]/)[1]