How I read this output: match at index 0 and ending at 1
match at index 1 and ending at 1 **
match at index 2, ending at 3
match at index 3, ending at 3 **
On lines 2 and 4 of output: I don't know whether to call this a match since it's actually "b". BUT, the way I interpret this is that ? is a greedy quantifier and needs to include all the chars in the String and (according to K&B book) is a zero or one quantifier. Because of this it has to include even the characters that are a 0 quantifier or 0 match to the pattern. Can someone correct or validate this thought.
Also, is ? as a greedy quantifier always a zero or one quantifier OR does it change based on combinations etc.? And is this true in regards to other quantifiers? I've read over the Oracle/java tutorial and still a little confused. Thanks!
is ? as a greedy quantifier always a zero or one quantifier OR does it change based on combinations etc.?
As a quantifier, yes, the ? is always 'zero-or-one' but when it follows a quantifier it signifies a lazy, or reluctant match. You'll find more (much more) in the other pages of the tutorial I've linked.
There are no new questions, but there may be new answers.
Regex is a HUGE topic. Entire books have been written about regex.
But, the SCJP exam doesn't go too far into the complexities of this tool. So, while regex is a very interesting topic, in terms of studying for the SCJP you don't have to dig deeper than what we cover in K&B.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)