“如果”给了我更多的答案..如何只得到第一?谢谢人们。 http://jsfiddle.net/TsxBy/
var content = "var=xyz-id=2,var=abc-id=1,var=bcd-id=7,var=abc-id=1,var=hij-id=4,var=xyz-id=2";
content = content.split(',');
for (i = 0; i < content.length; i++) {
var temp = content[i].match(/\d/);
if (temp == '1') {
alert('match 1'); // how to response only first "matched"?
}
if (temp == '2') {
alert('match 2'); // same here
}
}