查找字符串中指定字符

1.查找字符串中指定字符

String qqBrowser = "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0; QQBrowser/7.7.28658.400) like Gecko";//字符串

String regStr = "QQBrowser";//查找指定字符
Pattern pattern = Pattern.compile(regStr);
Matcher matcher = pattern.matcher(qqBrowser);

boolean result = matcher.find();

if(result){

System.out.println("找到QQBrowser字符");

}else{

System.out.println("未找到QQBrowser字符");

}

你可能感兴趣的:(Java)