JavaScript tips — Non-greedy (lazy) matching in regular expressions

preview_player
Показать описание
Non-greedy (lazy) quantifiers in JavaScript regular expression try to match as few times as possible. You write them by adding a ? after a quantifier such as + or *, so a+? or (xyz)*?

In non-greedy mode, instead of matching as much as possible, the quantifier will match as little as possible to make the regular expression succeed

#javascript #regex #regularexpressions
Рекомендации по теме
Комментарии
Автор

Learned something new today :)
Thanks.

nicolasparada