Lazy quantifier in regex ?
Add ?
at the behind *
or +
to make them less greedy.
const sentence = `a "witch" and her "broom" is one`;
sentence.match(/".+"/); // `"witch" and her "broom"`
// lazy
sentence.match(/".+?"/); // `"witch"`
Lazy quantifier in regex ?
Add ?
at the behind *
or +
to make them less greedy.
const sentence = `a "witch" and her "broom" is one`;
sentence.match(/".+"/); // `"witch" and her "broom"`
// lazy
sentence.match(/".+?"/); // `"witch"`