一、Pattern类
Pattern对象是一个正则表达式对象,Pattern类没有公共构造方法。创建一个Pattern对象,调用其公共的静态方法,它返回一个Pattern对象。该方法接受一个正则表达式作为它的第一个参数。
package com.jun.regexp;
import java.util.regex.Pattern;
/**
* matches方法,用于整体匹配,验证输入的字符串是否满足条件使用
*/
public class PatternMethod {
public static void main(String[] args) {
String content ="hello word,你好";
String regStr ="hello.*";
boolean matches = Pattern.matches(regStr, content);
System.out.println("整体匹配:"+matches);
}
}