Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regex

 
joshua antony
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why am I not getting any output in the above case?
 
Dave McIntyre
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic