publicclassMyTest{
pubic staticvoidmain(String[] args){
String s ="奥巴马和普京是朋友".replace("奥巴马","*").replace("普京","*")
String s ="奥巴马和普京是朋友".replaceAll("奥巴马","*")
String s1 ="121321awewrw12324sdfsdf131312sdfsd";
String s1 = s1.replaceAll("[0-9]","")}}
7.常见对象(Pattern和Matcher的概述
// pattern 模式器用来封装一个正则表达式//matcher匹配器可以封装一个待匹配的数据//可以通过匹配器中的方法进行匹配//获取一个模式器
Pattern p = Pattern.compile("a*b*");//通过模式器获取一个匹配器
Matcher m = p.matcher("aaaaab");//进行匹配boolean b = m.matches
System.out.println(b);//如果你想看字符串符不符合正则表达式规则,那就使用matches()方法boolean matches ="aaaaab".matches("a*b*");
System.out.println(b);
String str ="da jia ting wo shuo ,jin tian yao xia yu ,bu shang wan zi xi";
String str1 ="[a-z]{3}";
Pattern p = Pattern.compile(str1);
Matcher m = p.matcher(str);boolean b = m.find();if(b){
String g = matcher.group();
System.out.print(g);}
1.补充Integer //int-------stringint num = 100; Integer integer = new Integer(num);String s = integer.tostring();System.out.println(s);String str = num +"";String str1 = String.valueof(num);...