It's not a secret anymore!
The moose likes Beginning Java and the fly likes greedy quantifier Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "greedy quantifier" Watch "greedy quantifier" New topic

greedy quantifier

Isaac Lee

Joined: Feb 25, 2005
Posts: 2
I have the following program :

I get the result like this:


For the program below:

I get the result :

I don't understand why the results are different. In my understanding, the first program should give the result 0f , the same as the second. why is it different?

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Please check your private messages for an important administrative matter.

[My Blog]
All roads lead to JavaRanch
Henry Wong

Joined: Sep 28, 2004
Posts: 20370

In the first case, the pattern is zero or one letter f. In the second case, the pattern is one or more letter f. It is the zero letter f part of the first pattern that allows the second match.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Isaac Lee

Joined: Feb 25, 2005
Posts: 2
Thank you. Henry
Rahul P Kumar
Ranch Hand

Joined: Sep 26, 2009
Posts: 188
[Deleted entire post as "hi-jack." Original in our "deleted" forum. CR]
It is sorta covered in the JavaRanch Style Guide.
subject: greedy quantifier
jQuery in Action, 3rd edition