Page 1 of 1

About Question enthuware.ocpjp.v7.2.1415 :

Posted: Wed Feb 26, 2014 12:03 pm
by vddoan
Hi,

this should match all propositions

because the . (dot) matches any single character (except the newline character), hence including the white space

I tested with the following code

public static void main(String[] args) {
String str1 = "CooLooLCuuL";
String str2 = "CooLooL and CuuL";
String str3 = "CooL and CuuL";
Pattern pattern = Pattern.compile("C.*L");
Matcher matcher = pattern.matcher(str3);

while (matcher.find()) {
System.out.println(matcher.start() + " " + matcher.group());
}
}

Viet

Re: About Question enthuware.ocpjp.v7.2.1415 :

Posted: Wed Feb 26, 2014 12:11 pm
by admin
The question is asking what words will the pattern capture in the given input. It is not asking what words will match the given pattern.