誰でも正規表現を手伝ってもらえますか? このコードはうまくいきます。
public static void main(String[] args) {
String s = "with name=successfully already exist\n";
Pattern p = Pattern.compile(".+name=.*successfully.+", Pattern.DOTALL);
java.util.regex.Matcher m = p.matcher(s);
if (m.matches()) {
System.out.println("match");
} else {
System.out.println("not match");
}
}
しかし、このコードは「一致しません」を返します。なんで?
public static void main(String[] args) {
String s = "with name=successfully already exist\n";
if (s.matches(".+name=.*successfully.+")) {
System.out.println("match");
} else {
System.out.println("not match");
}
}