public class RegDemo{
public static void main(String[] args) {
String tel="13800001111";
String reg="1[358]\\d{9}"; //1[358][0-9]{9}
boolean b=tel.matches(reg);
System.out.println(tel+":"+b);
}
}
public class RegDemo{
public static void main(String[] args) {
String str1="wang_yu_hang";
String str2="zhao fei ";
String str3="tang.chun.lai";
String [ ] strarr1=str1.split("_");
String [ ] strarr2=str2.split(" +");
String [ ] strarr3=str3.split("\\.");
for(String str:strarr1){
System.out.println(str);
}
}
}
public class RegDemo{
public static void main(String[] args) {
String str="helloworld";
str=str.replaceAll("o","xx");
System.out.println(str);
String ss = "tel12344556qq4564654add4646767";
ss= ss.replaceAll("\\d{4,}", "#"); //4个或4个以上的数字连在一起的换成#
System.out.println(ss);
}
}
public class RegDemo{
public static void main(String[] args){
Pattern p = Pattern.compile(“a*b”); //将正则表达式进行对象封装
Matcher m = p.matcher(“aaaaab”);//用正则表达式的方法matcher和字符串关联,获取对字符串操作的匹配对象
Matcher boolean b = m.matches();//通过Mather匹配器对象的方法对字符串进行操作
System.out.println(b); //匹配返回true,不匹配则返回false
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有