您的位置:首页 > 其它

获取<img src />正则表达式

2016-06-02 16:42 337 查看
从文本中获取<img>的src路径:

// String img = "<img.*src=(.*?)[^>]*?>"; // 获取图片url
String img = "src\\s*=\\s*\"?(.*?)(\"|>|\\s+)";// 获取图片src
Matcher matcher = Pattern.compile(img).matcher(picContent.getContent());
List<String> listImgSrc = new ArrayList<String>();
while (matcher.find()) {
listImgSrc.add(matcher.group());
// String o_path = matcher.group(1);
// int num = o_path.indexOf("/", o_path.indexOf("/") + 1);
// bashpath = o_path.substring(0, num + 1);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: