Differences Among Greedy, Reluctant, and Possessive Quantifiers
by, 04-26-2012 at 07:50 PM (749 Views)
Subtle difference is present b/w reluctant, greedy and possessive quantifiers.
Greedy ones are known as greedy as they enforce matchers to eat or read in the whole input string before the 1st match attempt. When 1st attempt of match gets failed, input string is back offed by the matcher by 1 character and then tries once again in which the process is repeated till the match is being found or no more characters have been left for backing off. It totally depends upon quantifier that was used in expression to try and match again one or zero characters.
However, reluctant quantifiers go other way round in which they take their start from input string beginning. After that, they eat reluctantly 1 character at matching time. Last thing is whole input string try.
Possessive quantifiers usually eat the whole input string and they just try once for matching. They never get back off and if they try to do so, it will permit whole match to get succeeded.