Skip to main content
5 of 5
Updated based on the revised question, and subsequent comments.
phils
  • 53k
  • 3
  • 84
  • 127

Based on the screenshot, you are only interested in quotes spanning multiple lines. Here's a patten for that:

"\\(``\\(?:[^'\n]\\|'[^'\n]\\)*'?\\)\n\\(?:.\\|\n\\)*?''"

Or in rx syntax:

(rx (seq (group "``" (zero-or-more (or (not (in "\n'"))
                                       (seq "'" (not (in "\n'")))))
                (zero-or-one "'"))
         "\n" (minimal-match (zero-or-more anything)) "''"))

Note that we handle single ' characters with this:

"\\(?:[^'\n]\\|'[^'\n]\\)*'?

Which says match zero-or-more repetitions of:

  1. Any single character which is neither ' nor a newline.
  2. A ' character followed by any single character which is neither ' nor a newline.

Followed optionally by a single ' immediately before the newline.


Group 1 is the part to highlight. e.g. with hi-lock-mode:

Hi-lock: (("\\(``\\(?:[^'\n]\\|'[^'\n]\\)*'?\\)\n\\(?:.\\|\n\\)*?''"
           (1 (quote hi-green-b) prepend)))
phils
  • 53k
  • 3
  • 84
  • 127