日期:2014-05-20 浏览次数:21500 次
public static void main(String[] args) throws Exception{ String sql = "select * from tb_person where 1=1 /*IF name!=null && !\"\".equals(name)*/ and personname = like '%/*name*/%' /*END*/"; Matcher m = Pattern.compile("/\\*.+?\\*/").matcher(sql); while(m.find()){ System.out.println(m.group()); } } 打印结果: /*IF name!=null && !"".equals(name)*/ /*name*/ /*END*/