java 正则表达式匹配字符串

时间:2022-11-17 18:40:12
private static List<String> getImage(String str){
List<String> tmp=new ArrayList<String>();
String regex="<img src=\"([^\"]+?)\" />";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
System.out.println(str);
while(matcher.find()){ tmp.add(matcher.group(1).toString()); }
return tmp;
}