function test12()
{
var r1=/word1([.*?]+)word2/;
var str1="word1need1word2word1need2word2";
var arr;
arr=r1.exec(str1);
arr=r1.exec(str1);
window.alert(arr[1]);
}
test12();
无法得到need2,只能得到need1
...全文
1122打赏收藏
js正则一问
function test12() { var r1=/word1([.*?]+)word2/; var str1="word1need1word2word1need2word2"; var arr; arr=r1.exec(str1); arr=r1.exec(str1); window.alert(arr[1]); } test12(); 无法得到need2,只能得到need1
function test12()
{
var r1=/word1(.*?)word2/;
var str1="word1need1word2word1need2word2";
var arr;
arr=r1.exec(str1);
arr=r1.exec(str1);
window.alert(arr[1]);
}