rt.jar/java.util.regex
源码类public final class Pattern implements java.io.Serializable类方法
//字符串正则表达式转换成真正的正则 public static Pattern compile(String regex)普通方法
//匹配结果
public Matcher matcher(CharSequence input)
//案例1
String str = "2021-10-24 00:00:00";
String regex = "\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
//step1 建立正则表达式
Pattern p = Pattern.compile(regex);
//step2 匹配结果
Matcher m = p.matcher(str);
//案例2
String str2 = "$.msg=管理员登陆成功;$.stateCode=1";
String regex2 = "\$[\.\w]+=[\u4e00-\u9fa5\w]+";
//step1 建立正则表达式
Pattern p2 = Pattern.compile(regex2);
//step2 匹配结果
Matcher m2 = p2.matcher(str2);



