help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select/highlight and *copy* matches of some regex


From: Stephen Berman
Subject: Re: Select/highlight and *copy* matches of some regex
Date: Mon, 27 Jun 2022 22:56:46 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

On Mon, 27 Jun 2022 17:52:48 +0200 Joost <joostkremers@fastmail.fm> wrote:

> Hi all,
>
> I've been looking for at least an hour for something that my Sublime-using
> colleagues seem to be able to do out of the box... Highlight all matches of
> some regex in the current buffer and then copy/kill *all* of those matches so
> that you can yank them in a new buffer.
>
> The first part, highlighting all matches, is not a problem. But I haven't
> found a way yet to then extract all matches.

Is this (suitably tweaked) good enough?

(let ((matches ""))
  (while (re-search-forward "lang=.." nil t)
    (setq matches (concat matches (match-string 0) "\n")))
  (kill-new matches))

Steve Berman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]