Regex to Extract Quoted Text
Use this when you need content between double quotes while tolerating escaped characters in logs or config snippets.
The expression
/"([^"\\]*(?:\\.[^"\\]*)*)"/gHow to read it
(?: … ) groups without capturing, so it costs nothing to read back.
A negated class [^ … ] matches anything except the listed characters.
Nested quantifiers — the shape behind catastrophic backtracking.
g — global — keep going after the first match instead of stopping
Find matches in your own text
no inputThis expression is unanchored, so it finds every occurrence anywhere in the text. Highlighted runs are what a replace call would rewrite.
Examples, checked in your browser
4/4 verifiedHe said "deploy now"
Matches.
"escaped \"quote\" ok"
Matches.
no quotes here
No match — this is the kind of input the pattern rejects.
'single quotes only'
No match — this is the kind of input the pattern rejects.
Use it in code
3 languagesconst regex = /"([^"\\]*(?:\\.[^"\\]*)*)"/g;
regex.test(input);import re
pattern = re.compile(r""([^"\\]*(?:\\.[^"\\]*)*)"")
bool(pattern.search(input))re := regexp.MustCompile("\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"")
matched := re.MatchString(input)