当前位置:Gxlcms > html代码 > html字符操作_html/css_WEB-ITnose

html字符操作_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:5人阅读

 public class Test { /**  * @Title: main   * @Description:  * @param args   * @author   * @date 2016年2月17日  * 1、去掉字符串中所有的标签,获取纯文本内容  * 2、获取html节点中img的src路径  */ public static void main(String[] args) {  String html = "

12132第一串字符


这是第二窜字符

"; Pattern p = Pattern.compile("]+src\\s*=\\s*['\"]([^'\"]+)['\"][^>]*>"); Matcher m = p.matcher(html); List srcs = new ArrayList(); while(m.find()){ srcs.add(m.group(1)); } String regex = "<[^>]*>"; String str = html.replaceAll(regex, ""); System.out.println(str+"\n"+srcs.get(0)); }}

人气教程排行