This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regex  RSS feed

 
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
Boost this thread!