Extraction
Match a quoted string
Flags: g
Extract text between double quotes, handling escaped quotes inside.
Pattern
Regular expression
"(?:[^"\\]|\\.)*"How it works
Matches a double-quoted string that may contain escape sequences like `\"` or `\\n`. Uses an alternation: non-quote/non-backslash, or a backslash followed by any character.
Matches
- ▸"hello"
- ▸"say \\"hi\\""
- ▸"line 1\nline 2"
Non-matches
- ▸"unterminated
- ▸no quotes
Common gotchas
This pattern is greedy and works line by line only if the string contains no unescaped newlines. For real code/JSON parsing, use a proper parser; regex-based string extraction breaks on edge cases.
Language snippets
JavaScript
const re = /"(?:[^"\\]|\\.)*"/g;Python
re.findall(r'"(?:[^"\\]|\\.)*"', text)Go
re := regexp.MustCompile(`"(?:[^"\\]|\\.)*"`)Java
Pattern.compile("\"(?:[^\"\\\\]|\\\\.)*\"")