js正则去掉所有html标签/某一特定字符

 1 java后台
 2     String str=hello你好吗,我很好 thank you????噼安胖胖                ";
 3        
 4         String reg = "[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]"; 
 5         Pattern pat = Pattern.compile(reg); 
 6         Matcher mat = pat.matcher(str);
 7         String s="";
 8         while (mat.find()){
 9             //你的代码             
10             s+=mat.group();            
11         }
12         System.out.println(s);//保留符合条件的数据

 

去掉所有html标签

data.replace(/<[^>]+>/g,"")

 

//去掉所有undefined显示
  function ifnull(elem){
    return elem.replace(/undefined/g,"");   
  }

 

/g表示全局匹配

 

posted @ 2016-02-04 10:27  flay  阅读(1960)  评论(0编辑  收藏  举报