/** * 返回单个字符串,若匹配到多个的话就返回第一个,方法与getSubUtil一样 * * @param soap * @param rgex * @return */ public static String getSubUtilSimple(String soap, String rgex) { Pattern pattern = Pattern.compile(rgex);// 匹配的模式 Matcher m = pattern.matcher(soap); while (m.find()) { return m.group(1); } return ""; } public static void main(String[] args) { String origin = "action.VenderAction$$EnhancerBySpringCGLIB$$4770aa03.update()"; origin = origin.replace(getSubUtilSimple(origin, "Action(.*?)\\."), ""); System.out.println(origin); }