Back reference and lazy matching # 17

Back reference



The lazy mode of quantifiers is the opposite of the greedy mode. It means: “repeat a minimal number of times”.

We can enable it by putting a question mark '?' after the quantifier so that it becomes *? or +? or even ?? for '?'.

To make things clear: usually a question mark (?) is a quantifier by itself (zero or one), but if added after another quantifier (or even itself) it gets another meaning – it switches the matching mode from greedy to lazy.






Post a Comment

Previous Post Next Post