public class Test {
public static String DeleteWord(String s){
String regex = "[T,t][H,h][E,e]";
return s.replaceAll(regex,"");
}
public static void main(String args[]){
String s = "The World! thE asd THE fgrg";
//以该字符串为例,删除字符串中所有的 "The" 单词,不区分大小写
System.out.println(DeleteWord(s));
}
}
删除字符串中的某指定单词(不区分大小写)
最新推荐文章于 2023-03-15 23:54:31 发布