Meta Sequences:
.
(a dot) It denotes “any character except a newline”
Quantifiers:
+
to the match one character after another.?
is a quantifier by itself (zero or one), but if added after another quantifier (or even itself) it gets another meaning – it switches the matching mode from greedy --> to --> lazy.
let regex = /".+"/g
let str = `a "witch" and her "broom" is one...`
str.match(regex)
// "witch" and her "broom"
It means: “repeat minimal number of times”.
let regex = /".+?"/g
let regexAlternativeApproach = /"[^"]+"/g;
let str = `a "witch" and her "broom" is one...`
str.match(regex)
// "witch"
// "broom"
g
guarda um state de lastIndex. Não é exatamente regex, mas a implementação do js. Se tem o ^ e $ tem pouco motivo pra usar /g. - https://stackoverflow.com/questions/1520800/why-does-a-regexp-with-global-flag-give-wrong-results