• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regex ".*+foo"

 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Jim, I think I've got it now!

Yours,
Bu.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic