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
About Question enthuware.ocpjp.v7.2.1415 :
Moderator: admin
-
- Posts: 2
- Joined: Fri Feb 21, 2014 9:42 am
- Contact:
-
- Site Admin
- Posts: 10075
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1415 :
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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 8 guests