re: A regex cheatsheet for all those regex haters (and lovers) 👀 VIEW POST

FULL DISCUSSION
 

Hey @catherinecodes , I think you've missed the greedy vs lazy matching:

// greedy
/".+"/.exec('a "witch" and her "broom" is one') // "witch" and her "broom"
// lazy
/".+?"/.exec('a "witch" and her "broom" is one') // "witch"
 
 

You can achieve laziness with negated set too:

/"[^"]+"/.exec('a "witch" and her "broom" is one') // "witch"
code of conduct - report abuse