标签:nal split system ast com case out print map
private final static Pattern ATTR_PATTERN = Pattern.compile("<img[^<>]*?\\ssrc=[‘\"]?(.*?)[‘\"]?\\s.*?>",Pattern.CASE_INSENSITIVE);
String imgList = "";
String img = "";
if(StringUtils.hasText(content)){
Matcher matcher = ATTR_PATTERN.matcher(content);
while (matcher.find()) {
imgList += matcher.group(1) + ",";
}
System.out.print(imgList);
}
//如果获取到了文章中的图片
if(!imgList.equals("")){
//如果有两张或两张以上,取第一张,否则就直接第一张
if(imgList.contains(",")){
String[] split = imgList.split(",");
img=split[0];
}else {
img=imgList;
}
//newMap.put("img",img);
}
标签:nal split system ast com case out print map
原文地址:https://www.cnblogs.com/XiaoheBlogs/p/12312746.html