pattern表示正则表达式,接收正则表达式作为参数
例子:
String content = "my name is gaojiufeng"; String pattern = ".*gaojiufeng.*"; boolean isMatch = Pattern.matches(pattern,content); System.out.println("字符串是否包含了gaojiufeng?"+isMatch);
.*代表任意字符串
pattern表示正则表达式,接收正则表达式作为参数
例子:
String content = "my name is gaojiufeng"; String pattern = ".*gaojiufeng.*"; boolean isMatch = Pattern.matches(pattern,content); System.out.println("字符串是否包含了gaojiufeng?"+isMatch);
.*代表任意字符串