我想 过虑掉所有HTML的标记 只显示内容 比如:
"<div onMouseOver=this.className='onselect' onMouseOut=this.className='' onDblClick='document.all.msg.value=document.all.msg.value+this.innerText'><font color=#ff0000>[Fri Sep 01 17:01:40 CST 2006]客服<br><font face='宋体' color=' 'style='font-size: px;line-height:10px'>你好,我是客服</font></font></div>"只显示 "客服 你好,我是客服"我找了好多JAVASCRIPT和VBSCRIPT的方法 都是用正则表达式 觉得都不好用 请问有没有用JAVA实现的方法啊,谢谢.

解决方案 »

  1.   

    用JAVA肯定也是匹配表达式,一样的
      

  2.   

    那在JAVA中 怎么使用正则表达式啊? 请求支援 谢谢
      

  3.   

    有没有JAVA的方法 我在网上找了好长时间 死活没有 急死我了
      

  4.   

    String str="";
    str=str.replaceAll("<[^<>]+>","");
    直接使用正则替换即可
      

  5.   

    str.replaceAll("<[^>]*>","");
      

  6.   

    dreamover(梦醒了〖http://hellfire.cn〗) 和 lip009(深蓝忧郁) 
    我用了你们的方法 可是我传进
    "<div onMouseOver=this.className='onselect' onMouseOut=this.className='' onDblClick='document.all.msg.value=document.all.msg.value+this.innerText'><font color=#ff0000>[Fri Sep 01 17:01:40 CST 2006]客服<br><font face='宋体' color=' 'style='font-size: px;line-height:10px'>你好,我是客服</font></font></div>"这个参数 输出什么都没有啦啊 请问是为啥??
      

  7.   

    String str="<div onMouseOver=this.className='onselect' onMouseOut=this.className='' onDblClick='document.all.msg.value=document.all.msg.value+this.innerText'><font color=#ff0000>[Fri Sep 01 17:01:40 CST 2006]客服<br><font face='宋体' color=' 'style='font-size: px;line-height:10px'>你好,我是客服</font></font></div>";
        str=str.replaceAll("<[^<>]+>","");
    经测试以上代码完全正确,测试输出结果:
       [Fri Sep 01 17:01:40 CST 2006]客服你好,我是客服
      

  8.   

    class Test {
    public static void main(String[] args) {
    String str = "<div onMouseOver=this.className='onselect' onMouseOut=this.className='' onDblClick='document.all.msg.value=document.all.msg.value+this.innerText'><font color=#ff0000>[Fri Sep 01 17:01:40 CST 2006]客服<br><font face='宋体' color=' 'style='font-size: px;line-height:10px'>你好,我是客服</font></font></div>";
    System.out.println(str.replaceAll("<[^>]*>",""));
    }
    }
    ---------- Run ----------
    [Fri Sep 01 17:01:40 CST 2006]客服你好,我是客服输出完成 (耗时: 0 秒) - 正常终止
      

  9.   

    to lip009(深蓝忧郁) ( ) 信誉:100    Blog 
    呵呵,两次都是发出来看到你的贴在上面
      

  10.   

    ?????
    lip009(深蓝忧郁) 
    能把你测试的代码放上来么 我这里怎么死活都是空的啊我这么写不对么??
    public class test {
        public String htmlFilter(String inputString) {
            String str = "";
            str=str.replaceAll("<[^<>]+>","");
            return str;
        }
        
        public static void main(String a[]){
            test aa = new test();
            System.out.println(aa.htmlFilter("<div onMouseOver=this.className='onselect' onMouseOut=this.className='' onDblClick='document.all.msg.value=document.all.msg.value+this.innerText'><font color=#ff0000>[Fri Sep 01 17:01:40 CST 2006] mahe<br><font face='宋体' color=' 'style='font-size: px;line-height:10px'>33333333333</font></font></div>"));
        }
    }
      

  11.   

    to: dreamover(梦醒了〖http://hellfire.cn〗) ( ) 信誉:100    Blog 
       
       嘿嘿...to: msdnweixiaomsdn(微笑) ( ) 信誉:100    Blog 把这行String str = "";改成
    String str=inputString;