Hi,
I am typing the following which is taken from Chapter 6 - pages 496 and 497
The way to think about this is to consider the name greedy. In order for the second answer to be correct, the regex engine would have to look (greedily) at the entire source data before it could determine that there was an xx at the end. So in fact, the second result is the correct result because in the original example we used the greedy quantifier *. The result that finds two different sets can be generated by using the reluctant quantifier *?. Let's review:
source: yyxxxyxx
pattern: .*xx
is using the greedy quantifier * and produces
0 yyxxxyxx
If we change the pattern to
source: yyxxxyxx
pattern: .*?xx
we're now using the reluctant qualifier *?, and we get the following:
0 yyxx
4 xyxx
The greedy quantifier does in fact read the entire source data, and then it works backward (from the right) until it finds the rightmost match. at that oint, it ncludes everything from earlier in the source data up to and including the data that is part of the rightmost match.
I am not able to understand the text that I have highlighted in red. Could someone please help me to understand this portion.