Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regex 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 "Regex" Watch "Regex" New topic
Author

Regex

joshua antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 117

Why am I not getting any output in the above case?
Dave McIntyre
Greenhorn

Joined: Oct 22, 2006
Posts: 8
The quantifier *+ is a possessive quantifier. From the API:
Possessive quantifiers, which greedily match as much as they can and do not back off, even when doing so would allow the overall match to succeed.

So the .*+ matches as much as it can (which is the whole of the string) and there is none of the string left to match the "hello" part of the pattern.
joshua antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 117
Thanks Dave
 
Consider Paul's rocket mass heater.
 
subject: Regex
 
Similar Threads
Doubt in EL
Total number of object string creates?
a simple question
Dynamic Method Call
java.lang.StringIndexOutOfBoundsException: String index out of range: -2