๐ฐgreedy vs. lazy
๐ง under construction
JS โฉ value โฉ object โฉ regex โฉ pattern โฉ repeat
quantifiers are
normally greedy (match as much as possible),
when followed by
?
they become lazy (match as little as possible).
regex matches
------------------------------------------------------
+ b\w+ be bee beer beers (greedy)
โฐโฏ โฐโโฏ โฐโโโฏ โฐโโโโฏ
+? b\w+? be bee beer beers (lazy)
โฐโฏ โฐโฏ โฐโฏ โฐโฏ
๐ฏ synonyms๏ผ "quantifier"
When using a repetition operator, consider the lazy variant first.
Last updated
Was this helpful?