Regex patterns/Text & extraction
Quoted string with escapes
The unrolled loop — matches "a \"quoted\" string" without catastrophic backtracking.
/"[^"\\]*(?:\\.[^"\\]*)*"/gThe problem
Match a double-quoted string that may contain escaped quotes, without stopping at the first escaped one.
How it reads
Follow the line from left to right — every path you can trace is a string this pattern matches.
"[^"\\]*(?:\\.[^"\\]*…In order:"The character """[^"\\]*Any character except """ or "\", any number of times, including none, as many as possible(?:\\.[^"\\]*)*Repeated any number of times, including none, as many as possible:(?:\\.[^"\\]*)Group (not captured):\\.[^"\\]*In order:\\The character "\".Any character (except a line break, unless the s flag is set)[^"\\]*Any character except """ or "\", any number of times, including none, as many as possible"The character """
Matches
- "hello"
- a "quoted" string
- "with \"escapes\" inside"
Does not match
- no quotes here
- 'single quoted'
Where it bites
- The shape is deliberate: "normal* (special normal*)*" — each character can be consumed in exactly one way, so a failure cannot be retried a different way. That is what makes it linear.
- The tempting "(\\.|[^"])*" version has two branches that can both match the same character, which is the overlapping-alternatives ReDoS shape. Paste it into the tool and watch the step count.
- It does not handle single quotes or template literals — add branches if you need them.