Regex to Extract Quoted Text

All patterns
Extraction26 chars · /g

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

/"([^"\\]*(?:\\.[^"\\]*)*)"/g

How 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.

gglobal — keep going after the first match instead of stopping

Find matches in your own text

no input
Try:

This 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 verified

He 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 languages
JavaScript
const regex = /"([^"\\]*(?:\\.[^"\\]*)*)"/g;
regex.test(input);
Python
import re
pattern = re.compile(r""([^"\\]*(?:\\.[^"\\]*)*)"")
bool(pattern.search(input))
Go
re := regexp.MustCompile("\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"")
matched := re.MatchString(input)

Other extraction patterns

4
GroupExtraction
Flags/g
Examples4
SafetyOK