The best ui-com="com4" things in life are free ui-com="com_3" ui-com="com5"
我要通过js快速得到ui-com的所有值,比如com4、com3等,求正则大神看看,麻烦了!
弑天下
浏览 591回答 4
4回答
GCT1015
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就是需要的值
}