Consider the following code snippet. What will be the output of this code?
import java.util.regex.*;
public class Main {
public static void main(String[] args) {
String regex = "a*b";
String input = "aaab";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
System.out.println(matcher.matches());
}
}
true
false
aaab
Compile-time error
This question is part of this quiz :
Java Regex Basics and Pattern Matching