[Advanced-java] Regular expressions

David Rosenstrauch david.rosenstrauch at aleri.com
Fri Jun 27 18:25:00 2003


Look at this example:

RegEx1:	a.*b	(greedy)
RegEx2:	a.*?b	(reluctant)


If you match both of these against the input "abbbb", the matches would be:

RegEx1:	abbbb
RegEx2:	ab

(I think.  This is off the top of my head, haven't run it through a regex 
test, so don't shoot me if I'm wrong.)

In any case, basic concept is:  greedy: consume as much as possible and still 
match; reluctant: consume as little as possible and still match.

HTH,

DR


On Friday 27 June 2003 10:14 am, Moisei, Constantin wrote:
> Hello,
>
> I have a question about qualifiers: What would be the difference between
> the "Greedy Qualifiers" and "Reluctant Qualifiers" ? What about "Possessive
> Qualifiers" ?
>
> Any example would be greatly appreciated.
>
> Thanks in advance!
>
> Regards,
> "C"