This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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: 20029

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]
Have you checked out Aspose?
subject: greedy quantifier
It's not a secret anymore!