Noam Postavsky writes: > On 29 June 2018 at 10:52, John Shahid wrote: > >> (replace-regexp-in-string "\\(\n\n\\).*\\'" > > The trick is that "." matches anything but a newline, using (.\\|\n\\) > instead works as expected: > > (replace-regexp-in-string "\\(\n\n\\)\\(?:.\\|\n\\)*\\'" > "\n\ndoc\\1" > "foo\n\nbar\n\nbaz" > nil > nil > 1) Thanks that worked. Totally missed that "." doesn't match newlines in the documentation. attached a new patch with the fix.