wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "regex ".*+foo"" Watch "regex ".*+foo"" New topic
Author

regex ".*+foo"

Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
I'm not sure but according to the K&B book only greedy and reluctant quantifiers are on the exam.
Possesive q. aren't.
So perhaps SCJP is the wrong forum for my post.
But:
Does it mean we will never see a question like
What does "foo.*+" find in "xxfooxxxfoo" on the SCJP exam?

(It will find the same as "foo.*" find here,
fooxxxfoo 2-11
that's not what I'm interested in)

And I've found in the Sun Tutorial on regex that
.*+ does the same as .* does, but omits the backing off of characters.

If I've understood this right, can I then state:
The regex pattern ".*+foo"
can never ever find any match in any possible String?

I mean, if it first takes the whole string and then looks if there is a "foo" after that String, and does not back off, it can never find a match.
Or am I wrong?



Curious,
Bu.


all events occur in real time
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[BH]: Does it mean we will never see a question like
What does "foo.*+" find in "xxfooxxxfoo" on the SCJP exam?


Correct - the *+ is a possessive quantifier, and will not appear on the exam.

[BH]: If I've understood this right, can I then state:
The regex pattern ".*+foo"
can never ever find any match in any possible String?


Correct.


"I'm not back." - Bill Harding, Twister
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Thank you, Jim, I think I've got it now!

Yours,
Bu.
 
 
subject: regex ".*+foo"
 
Similar Threads
Journal Article - The SCJP Tip Line - Strings, Literally
SCJP question
SCJP
SCJP
SCJP