1

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

"^>\\s-*\n>"

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...

halloleo
  • 1,215
  • 9
  • 23

1 Answers1

0

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).

phils
  • 48,657
  • 3
  • 76
  • 115
  • I'll also link to https://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 '19 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 '19 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 '19 at 23:45
  • Done. :-) I have report this to the emacs bugs list – halloleo Jun 24 '19 at 14:19