package Test0914;
public class Mobile {
public static void main(String[] args) {
String mobile = "13856984571";
mobile = mobile.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
System.out.println(mobile);
}
}
138****4571
String.matches(regex)
String str = "abcdefefg";
String cmd = "<[^\\s]*>";
Pattern p = Pattern.compile(cmd);
Matcher m = p.matcher(str);
if(m.find()){
System.out.println(m.group());
}else{
System.out.println("not found");
}
String str="xingming:lsz,xingbie:nv";
String cmd="xingming:([a-zA-Z]*),xingbie:([a-zA-Z]*)"'
Pattern p = Pattern.compile(cmd);
Matcher m = p.matcher(str);
if(m.find()){
System.out.println("姓名:"+m.group(1));
System.out.println("性别:"+m.group(2));
}else{
System.out.println("not found");
}
String str= “abcaabadwewewe”;
String str2 = str.replaceAll("([a])([a]|[d])","*$2")
str2为:abc*ab*dwewewe
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有