I made the following code:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.lang.Math; // headers MUST be above the first class
// one class needs to have a main() method
public class HelloWorld
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{
String ori = "kdya";
String pa = "[kd]";
Pattern pat = Pattern.compile(pa);
Matcher mat = pat.matcher(ori);
System.out.println(mat.matches());
}
}
I want to match the start of the original String (the first character) with any character from the pattern list.
It does not match, but it does exist. What is wrong?