lohiecan (安哥拉鸡鸡 )- 2019-01-16 0 人
just test
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Main {
    public static void main(String[] args) {
        String str = "mm <a\n" +
                "href='http://www.baidu.com'\n" +
                "class='test'>\n" +
                "asdf</a>";
        Matcher m1 = Pattern.compile("(<[^<>]+)\\s*\\n\\s*").matcher(str);
        if (m1.find()) {
            System.out.println("结果:"+str.substring(0,m1.start())+ m1.group().replaceAll("\n"," ") +  str.substring(m1.end()));
        } else {
            System.out.println("not match!");
        }
    }
}
lohiecan (安哥拉鸡鸡 )- 2019-01-15 0 人
格式化html标签示例
let a="你好,我好,大家好,".replace(/好/g,'是中国人');
console.log(a);
lohiecan (安哥拉鸡鸡 )- 2019-01-15 0 人
替换所有指定字符串
class Main { 
    public static void main(String[] args) {  
        String contentString = 
        "sdfsd abc---abc <a href='http://www.123.com'>你好</a>" +  
        "<script   > ss('asdf');</script>"+
        "<style >ba {color:#FFF;}</style>"+
                "OKOK<img title='img' src='abc' />" +  
                "<!-- sdfsdfds --> good";  
        System.out.println("before:"+contentString);          
        contentString=contentString.replaceAll("(?i)<!--.*?-->", "");   
        System.out.println("after:"+contentString);  
    }  
}
 
lohiecan (安哥拉鸡鸡 )- 2019-01-14 0 人
正则去除HTML代码中的注释信息
class Main { 
    public static void main(String[] args) {  
        String contentString = 
        "sdfsd abc---abc <a href='http://www.123.com'>你好</a>" +  
        "<script   >xx('asdf');</script>"+
        "<style >ba {color:#FFF;}</style>"+
                "OKOK<img title='img' src='abc' />" +  
                "<!-- sdfsdfds --> good";  
        System.out.println("before:"+contentString);        
        contentString=contentString.replaceAll("(?i)(<SCRIPT)[\\s\\S]*?((</SCRIPT>)|(/>))", "");   
        System.out.println("after:"+contentString);  
    }  
}
 
lohiecan (安哥拉鸡鸡 )- 2019-01-14 0 人
正则去除HTML代码中的SCRIPT标签
class Main { 
    public static void main(String[] args) {  
        String contentString = 
        "sdfsd abc---abc <a href='http://www.123.com'>你好</a>" +  
        "<script   >xx('asdf');</script>"+
        "<style >ba {color:#FFF;}</style>"+
                "OKOK<img title='img' src='abc' />" +  
                "<!-- sdfsdfds --> good";  
        System.out.println("before:"+contentString);        
        contentString=contentString.replaceAll("<img[^>]*/>", " ");  
        System.out.println("after:"+contentString);  
    }  
}
 
lohiecan (安哥拉鸡鸡 )- 2019-01-14 0 人
正则去除HTML代码中的IMG标签