正则表达式



String s = "skuMap陈铨propertyMemoMap";
String rgex = "skuMap(.*?)propertyMemoMap";//明明就是有的,可以匹配的,但是就是一直匹配不到
s = s.replaceAll("\s*", "");//结果所有的回车符、空格符、换行符,就可以了
System.out.println(s);
String subUtilSimple = getSubUtilSimple(s, rgex);
//subUtilSimple  = 陈铨
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 "";
}


原文地址:https://www.cnblogs.com/itchenfirst/p/10124333.html