字符操作系统(字符操作模式)

lxf2023-03-17 12:23:01

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第一串字符公共课测试{/* * @ title:main * @ description:* @ paramargs * @ author * @ date 2016 . 2 . 17 * 1。移除字符串中的所有标签。获取纯文本内容* 2。获取HTML node */public static void main(string[]args){ string HTML = "[div]12132中img的src路径,第一串字符。


这是第二个通灵人物。

字符操作系统(字符操作模式)字符操作系统(字符操作模式)字符操作系统(字符操作模式)"; 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)); }}