正则表达式查找

来源:互联网 发布:2017淘宝刷法爆款 编辑:程序博客网 时间:2024/05/24 07:05
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<String> strs = new ArrayList<String>();
        while (m.find()) {
            strs.add(m.group(1));            
        }
        for (String s : strs){
        sql=sql.replace(s, "1=1");
        }
        System.out.println(sql);
0 0
原创粉丝点击