Lazy and greedy quantifiers in regular expressions
Published on in Regular expressions
Last updated on
Greedy quantifiers (the default, e.g. *
) match as much as possible.
Lazy quantifiers (e.g. *?
) match as little as possible.
Published on in Regular expressions
Last updated on
Greedy quantifiers (the default, e.g. *
) match as much as possible.
Lazy quantifiers (e.g. *?
) match as little as possible.
Published on in JavaScript and Regular expressions
Last updated on
How to convert
'/foo/bar/baz/'
into an array of
'/'
, '/foo/'
, '/foo/bar/'
, and '/foo/bar/baz/'
.
Example use case: building breadcrumb navigations.
Published on in JavaScript and Regular expressions
Last updated on
E.g. how to capture overlapping pairs of letters from the string 'abcde'
,
i.e. 'ab'
, 'bc'
, 'cd'
and 'de'
.
Spoiler: with lookahead and lookbehind assertions.