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); }