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

来源:互联网 发布:淘宝内容推广 编辑:程序博客网 时间:2024/05/07 14:33

从文本中获取<img>的src路径:

// String img = "<img.*src=(.*?)[^>]*?>"; // 获取图片urlString img = "src\\s*=\\s*\"?(.*?)(\"|>|\\s+)";// 获取图片srcMatcher 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);}

0 0
原创粉丝点击