java正则匹配${xxx} 排除单引号双引号内的内容,前提引号必须成对出现

    public static void main(String[] a) {

        String wpp = "select 1, ${mark} '``this is, `/message22` special mark`\" this is ${mark1} special mark\"' `/message` ${mark} ";

        String pp = "((?=([^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)(?=([^\\\']*\\\'[^\\\']*\\\')*[^\\\']*$))\\$\\{(.*?)}";

        String th = wpp.replaceAll(pp, "77777");
        System.out.println(th);
    }

  

posted @ 2021-04-07 10:24  史安良  阅读(877)  评论(0编辑  收藏  举报