<?xml version="1.0" encoding="gb18030" ?>
<td>
hello world
</td> 如上文本,我想用正则表达式(或其他方法)把 <?xml version="1.0" encoding="gb18030" ?>"去掉,只留下 "hello world" ,搞了一个下午都没搞好.
java.util.regex.Pattern;
java.util.regex.Matcher;
查了这两个类的javaDoc,可就是没搞店~~~~~~~~~
请各位给点提示,当然有例子最好了~~~~~~~~~谢谢!!!
<td>
hello world
</td> 如上文本,我想用正则表达式(或其他方法)把 <?xml version="1.0" encoding="gb18030" ?>"去掉,只留下 "hello world" ,搞了一个下午都没搞好.
java.util.regex.Pattern;
java.util.regex.Matcher;
查了这两个类的javaDoc,可就是没搞店~~~~~~~~~
请各位给点提示,当然有例子最好了~~~~~~~~~谢谢!!!
解决方案 »
- 关于float和double后面小数点数的问题
- 关于 java calendar 得使用? 急谢~
- 使用jacob时总是报错“com.jacob.com.ComFailException: Can't get object clsid from progid”这是怎么回事?
- java写文件问题
- 关于实现接口的问题
- 关于 J2SE和 eclipse
- 问从数据库读取记录写到txt文件的效率问题,记录数达几百万条,写到文件后一条记录占用txt文件的一行,请问效率如何保证,请写一下详细的
- 一个FlowLayout小问题
- 语法出错!!!!在线ing......
- 从 VC 转向 JAVA ,如何学好它?
- ant时出现异常:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
- byte stream与character stream倒底有什么不同???
{
public static void main(String[] args) throws Exception
{
java.util.regex.Pattern p=java.util.regex.Pattern.compile("<[^>]*>");
java.io.File file = new java.io.File("d://index.html");
java.io.FileReader reader=new java.io.FileReader("d:\\index.html");
java.io.BufferedReader in=new java.io.BufferedReader(reader);
String s;
StringBuffer sb=new StringBuffer();
while((s=in.readLine())!=null)
sb.append(s.replaceAll("<[^>]*>",""));
System.out.println(sb.toString());
}
}
index.html:<?xml version="1.0" encoding="gb18030" ?>
<td>
hello world
</td>
搞的我多迷糊了.我表达错了..
1.<?xml version="1.0" encoding="gb18030" ?>
<td>
hello world
</td>
不是一个文件,不是从文件里读,是一个字符串.2.我要显示<td>hello world</td>,刚刚搞错了.太糊涂了.不好意思了.