正则表达式查找

String sql = "where 1=1 and $P{name} and 1=1 and $P{safa_fs232}";
Pattern p = Pattern.compile("(\\$(P|P!)\\{.*?\\})");
        Matcher m = p.matcher(sql);
        ArrayList strs = new ArrayList();
        while (m.find()) {
            strs.add(m.group(1));            
        }
        for (String s : strs){
        sql=sql.replace(s, "1=1");
        }
        System.out.println(sql);

你可能感兴趣的:(java)