Styles
#First way
Pattern p = Pattern.compile(".s", Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher("aS");
boolean s1 = m.matches();
System.out.println(s1); // Outputs: true
#Second way
boolean s2 = Pattern.compile("[0-9]+").matcher("123").matches();
System.out.println(s2); // Outputs: true
#Third way
boolean s3 = Pattern.matches(".s", "XXXX");
System.out.println(s3); // Outputs: false
Comments