- public class AAA {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //替换
- String tel="1580002584";//158****2584
- demo3(tel);
- }
- public static void demo3(String tel){
-
- // 找到第一组
- myReplace(tel,"(\\d{3})\\d{3}","$1****");
-
- }
- private static void myReplace(String retel, String regex, String ss) {
- // TODO Auto-generated method stub
- retel = retel.replaceAll(regex, ss);
- System.out.println(retel);
- }
- }
复制代码
找到一组就够了 |