Hice el siguiente código:
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());
}
}
Quiero emparejar el inicio del String original (el primer carácter) con cualquier carácter de la lista del patrón.
No empareja, pero sí que existe. ¿Qué está mal?