日期:2014-05-16 浏览次数:20502 次
var test = "<span>123123<?JS1231231</span>2JS?>123123<?JS12JS?><span>3</span><?JS13JS?>"; var reg = new RegExp("<\\?JS(.*?)JS\\?>", "g"); test.replace(reg, function(element) { alert(element); });
var test = "<span>123123<?JS123123\n1</span>2JS?>123123<?JS12JS?>\r\n<span>3</span><?JS \n13JS?>"; var reg = new RegExp("<\\?JS(.*?)JS\\?>", "g"); test.replace(reg, function(element) { alert(element); });
import java.util.regex.Matcher; import java.util.regex.Pattern; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub String test = "<span>123123<?JS123123\r\n1</span>2JS?>123123<?JS12JS?>\r\n<span>3</span><?JS \n13JS?>"; Pattern pattern = Pattern.compile("<\\?JS.*?JS\\?>", Pattern.DOTALL); Matcher matcher = pattern.matcher(test); while(matcher.find()) { System.out.println(matcher.group(0).trim()); } } }
var reg = new RegExp("<\\?JS([\\S\\s]*?)JS\\?>", "g");
------解决方案--------------------