PatternRegex

Match text in double quotes

Pull the phrase between a pair of double quotes out of a transcript, article, or log line for quick extraction.

Last updated

Patterng
"[^"\n]*"
Open in Regex Tester & Builder

Matches

  • She said "hello there" to him
  • The sign read "Open 24 hours" by the door

Doesn’t match

  • No quotes in this sentence
  • A single " mark with no partner

Why it’s written this way

The pattern opens on a literal double quote, then [^"\n]* greedily consumes any run of characters that is neither another quote nor a newline, before a closing double quote ends the match.

Excluding \n from the middle class keeps a single stray quote from swallowing everything up to the next quote several lines down — each match stays confined to one line.

Edge cases to know

  • It has no concept of an escaped quote, so a string containing \"hi\" as an escaped pair ends the match at that embedded quote rather than the intended closing one.
  • Curly or ‘smart’ quotes from a word processor aren't recognized at all — only the straight ASCII double quote counts.
  • An odd number of quote characters in the text leaves the final one unmatched rather than flagged as an error; the pattern simply stops finding pairs.

Related in Patterns