1 /**
 2      * 提取HTML标签的属性值
 3      * @param source HTML标签内容 
 4      *      "<span r
 5      * @param element 标签名称    a
 6      * @param attr 标签属性   title
 7      * @return
 8      */
 9     public static List<String> match(String source, String element, String attr) {
10         List<String> result = new ArrayList<String>();
11         String reg = "<" + element + "[^<>]*?\\s" + attr + "=['\"]?(.*?)['\"]?\\s.*?>";
12         Pattern pt = Pattern.compile(reg);
13         Matcher m = pt.matcher(source);
14         while (m.find()) {
15             String r = m.group(1);
16             result.add(r);
17         }
18         return result;
19     }

 

相关文章:

  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-14
猜你喜欢
  • 2022-12-23
  • 2021-09-24
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2021-06-04
相关资源
相似解决方案