public static void main(String[] args) {
// TODO Auto-generated method stub
Pattern pat = Pattern.compile("<img (.*)alt*>");
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
Matcher mat = pat.matcher(input);
boolean resulet= mat.find();
if (resulet == true){
System.out.println("yes, i find it");
}
else
System.out.println("no");}我输入的是 没有匹配到这个,麻烦各位了。
7 回答
慕村225694
TA贡献1880条经验 获得超4个赞
牧羊人nacy
TA贡献1862条经验 获得超7个赞
String regex = "";//""; Pattern pattern = null; Matcher matcher = null; try { pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); matcher = pattern.matcher(str); while (matcher.find()) { System.out.println("=====find it.======"); } } catch (PatternSyntaxException e) { e.printStackTrace(); System.exit(0); }
添加回答
举报
0/150
提交
取消