用java 滤文本中的HTML标签(简单)
2008-05-05 17:03
585 查看
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sense.test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author tenking
*/
public class Html2Text {
/**
* @param args the command line arguments
*/
public static String html2Text(String str){
Pattern pattern = Pattern.compile("<[.[^<]]*>");
Matcher matcher = pattern.matcher(str);
str = matcher.replaceAll("");
return str;
}
public static void main(String[] args) {
String s = new String();
s = "<html><head></head><body><table><tr><td>呵呵,看看HTML标签去掉没有</td></tr></table><img src=\"http:////:www.nneye.com\"/></body></html>";
System.out.println(html2Text(s));
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sense.test;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author tenking
*/
public class Html2Text {
/**
* @param args the command line arguments
*/
public static String html2Text(String str){
Pattern pattern = Pattern.compile("<[.[^<]]*>");
Matcher matcher = pattern.matcher(str);
str = matcher.replaceAll("");
return str;
}
public static void main(String[] args) {
String s = new String();
s = "<html><head></head><body><table><tr><td>呵呵,看看HTML标签去掉没有</td></tr></table><img src=\"http:////:www.nneye.com\"/></body></html>";
System.out.println(html2Text(s));
}
}
相关文章推荐
- 用java 滤文本中的HTML标签(简单)
- java工具类:文本中去除html标签
- Java正则去除文本中的HTML标签
- JAVA 过滤标签将html内容转换为文本
- Java 获取Html文本中的img标签下src中的内容
- java工具类:文本中去除html标签
- java过滤html标签获取纯文本信息的实例
- 简单的将一个html(xml)文本中的img标签(图片)提取出来的方法
- Java过滤任意(script,html,style)标签符,返回纯文本--封装类
- HTML标签之简单的文本格式化
- Java过滤任意(script,html,style)标签符,返回纯文本--封装类
- HTML学习笔记-----简单文本标签举例
- Java过滤任意(script,html,style)标签符,返回纯文本--封装类
- Java 获取Html文本中的img标签下src中的内容
- java过滤html标签获取纯文本信息
- Java过滤任意(script,html,style)标签符,返回纯文本--封装类
- 关于java 获取 html select标签 下拉框 option 文本内容 隐藏域
- java 中过滤文本的HTML标签
- Java 获取Html文本中的img标签下src中的内容方法
- Java 去除HTML标签转化成纯文本