有一段字符串如下:The best ui-com="com4" things in life are free ui-com="com_3" ui-com="com5"
我要通过js快速得到ui-com的所有值,比如com4、com3等,求正则大神看看,麻烦了!
2 回答
忽然笑
TA贡献1806条经验 获得超5个赞
var reg = /ui-com=".*?"/g;var str = 'The best ui-com="com4" things in life are free ui-com="com_3" ui-com="com5"';var arr = str.match(reg);if(arr==undefined||arr.length==0)
{ return false;
}for (var i = 0; i < arr.length; i++) { var tempstr1 = arr[i].replace(/ui-com="/, ""); var tempstr2 = tempstr1.replace(/"/, "");
alert(tempstr2);//tempstr2就是需要的值}- 2 回答
- 0 关注
- 1036 浏览
添加回答
举报
0/150
提交
取消
