I built with M-x re-builder a regex to match empty quoted lines in emails. In read syntax it is:


How can I copy this regex in re-builder, so that I can paste it in the first prompt of M-x replace-regexp?

I tried the following:

After writing the regex in re-builder's read mode I switched with Ctrl-C TAB to string syntax and copied the regex via Ctrl-C Ctrl-w. Then I issued M-x replace-regexp and pasted the regex but found "0 occurrences". Additionally I deleted the " quotes characters from the pasted text and try again, but still got no matches. I guess, something goes wrong with the newline character...


1 Answer 1


You're almost doing the right thing -- switch to string syntax, and copy the pattern, sans the double-quotes.

You need to copy it directly from the re-builder buffer using the normal copy/kill commands though, as C-c C-w always gives you the regexp in read syntax.

Regarding the newline, that should be a literal newline character at this point, and not the escape sequence \n (which won't match a newline in this syntax).

  • I'll also link to emacs.stackexchange.com/q/5568/454 in case any of that is useful (although you clearly understand the key parts of that already).
    – phils
    Jun 22, 2019 at 11:49
  • Thanks, that's it. Copying by hand is the way to do it. - A bit strange though that C-c C-w doesn't do it...
    – halloleo
    Jun 22, 2019 at 14:29
  • You should M-x report-emacs-bug for a feature-request. I think an option to copy in the current syntax would be useful.
    – phils
    Jun 22, 2019 at 23:45
  • Done. :-) I have report this to the emacs bugs list
    – halloleo
    Jun 24, 2019 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.