不包含特定字符串的Java正则表达式。
示例
import java.util.regex.*;
class PatternMatch{
public static void main(String args[]) {
String content = "I am a student";
String string = ".*boy.*";
boolean isMatch = Pattern.matches(string,content);
System.out.println("The line contains 'boy'?"+ isMatch);
}
}输出结果
the line contains 'boy'?false
火柴()
用于检查整个文本是否与模式匹配。其输出为布尔值。如果找到匹配项则返回true,否则返回false。这是使用Regex搜索文本中字符串的最简单方法之一,还有另一种方法compile(),如果您要进行CASEINSENSITIVE搜索或要搜索多次出现可以使用。
对于上面的示例,它将是-
String content = "I am a student"; String string = ".*BoY."; Pattern pattern = Pattern.compile(string, Pattern.CASE_INSENSITIVE);
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短