'<img abc 123 width="168" height="300"'.match(/(?=(width="))168/)
我期望从一个字符串中 取出其中位于width="123" 中的123
我先说一下我能想到的。但是这样的操作都感觉怪怪的。有没有炫酷的方法
使用replace然后在回调里面获取;
'<img abc 123 width="168" height="300"'.replace(/width="\d+"/,function(a){console.log(a)})或者是如同,@ars_qu 那样
'<img abc 123 width="168" height="300"'.match(/width="\d+"/)[0].match(/\d+/)[0]
相关分类