public boolean methes(String regex)
此方法是:字符串是否匹配給定的正則表達式
用法:str.methes(regex);
例子1:
public static void main(String args[]){
String a = "0";
String b = "\\d";
System.out.println(a.matches(b));
}
注:\\d表示0—9數字,所以a.matches(b)放回true。
例子2:
public static void main(String args[]){
String a = "99(jhkh00";
String b = "^[a-zA-Z0-9]+$";
System.out.println(a.matches(b));
}
注:放回false