java 正则表达式获得html字符串中<img src>中的src中的url地址
发布日期:2021-06-24 18:19:31 浏览次数:4 分类:技术文章

本文共 693 字,大约阅读时间需要 2 分钟。

public static Set
getImgStr(String htmlStr) {
Set
pics = new HashSet<>(); String img = ""; Pattern p_image; Matcher m_image; // String regEx_img = "
]*?>"; //图片链接地址 String regEx_img = "
]*?>"; p_image = Pattern.compile (regEx_img, Pattern.CASE_INSENSITIVE); m_image = p_image.matcher(htmlStr); while (m_image.find()) {
// 得到
数据 img = m_image.group(); // 匹配
中的src数据 Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(img); while (m.find()) {
pics.add(m.group(1)); } } return pics; }

转载地址:https://blog.csdn.net/weixin_34248258/article/details/86398851 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Android-FragmentPagerAdapter刷新无效的解决方案
下一篇:关于澳洲移民

发表评论

最新留言

不错!
[***.144.177.141]2024年04月23日 21时08分48秒