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: tomas
Subject: Re: Select/highlight and *copy* matches of some regex
Date: Tue, 28 Jun 2022 06:42:37 +0200

On Mon, Jun 27, 2022 at 10:56:46PM +0200, Stephen Berman wrote:
> 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))

Nifty :)

You'll end up with one big string of all concatenated matches.
But it's a start.

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

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