String replaceAll(String regex,String str)满足正则表达式的部分替换为给定内容
package seday02;
/**
* * String replaceAll(String regex,String str)
* @author xingsir
*/
public class ReplaceAllDemo {
public static void main(String[] args) {
//将当前字符串中满足正则表达式的部分替换为给定内容
String str="hello123java456abc";
String str2=str.replaceAll("[a-z]+", "#number#");
System.out.println(str2);
// 禁止,文明语言
String regex= "(fuck|tmd|SB|CAO)";
String message="fuck you ,你是SB,CAO蛋,tmd";
message=message.replaceAll(regex,"***");
System.out.println(message);
}
}