刚刚花了好长时间也没找到解决办法,只好把换行符号删掉后再匹配:
var str=“adfasdf\nadsfadsf\nasdfas\n”;
str=str.replace(new RegExp(""\n","gm"),"");
var arr=str.match(new RegExp("<select(.*?)</select>"));//extract the select panel
arr[0] arr[1]
var arr=str.match(new RegExp("<select(.*?)</select>"));//extract the select panel
arr[0] arr[1]