File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regular Expresion Question - reluctant quantifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Regular Expresion Question - reluctant quantifier" Watch "Regular Expresion Question - reluctant quantifier" New topic
Author

Regular Expresion Question - reluctant quantifier

Anu Charitha
Greenhorn

Joined: Apr 07, 2009
Posts: 4
Hello Everybody,

I am java newbie preparing for scjp 5. I started my prep with K&B chap 6. I am at regex.



I am not able to figure out why this would not match any x's. Could anybody please clarify. Thanks for help.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9304
    
  17

Hi Anu, welcome to javaranch.

Well when you use the *? reluctant quantifier, then as its name suggests, it will try to match as less as possible. This kind of things have been asked many times before. Maybe these few discussions might clear your doubt

http://www.coderanch.com/t/418121/Programmer-Certification-SCJP/certification/group-Matcher-class
http://www.coderanch.com/t/425642/Programmer-Certification-SCJP/certification/Pattern-Matching

If you still have doubts, then please ask...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Anu Charitha
Greenhorn

Joined: Apr 07, 2009
Posts: 4
Thanks Ankit, now I know why x's are not being matched.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regular Expresion Question - reluctant quantifier