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: Emanuel Berg
Subject: Re: Select/highlight and *copy* matches of some regex
Date: Tue, 28 Jun 2022 21:52:13 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

Visuwesh wrote:

> I wonder if you can use C-u M-s o for the job. I did C-u M-s
> o lang=.. then it produced a buffer with the contents
>
>     lang=en
>     lang=de
>     lang=fr
>     lang=pt

(require 'cl-lib)

(cl-loop
 while (re-search-forward "lang=\\([[:alnum:]]*\\)" (point-max) t)
 with hits = ()
 do (push (match-string-no-properties 1) hits)
 finally return
   (sort (cl-delete-duplicates hits :test #'string=) #'string<) )

;; blah blah lang=en bla
;; lang=de
;; lang=fr blah blah
;; blah lang=pt

;; blah blah lang=en bla
;; lang=de
;; lang=fr blah blah
;; blah lang=pt

;; result: ("de" "en" "fr" "pt")

-- 
underground experts united
https://dataswamp.org/~incal




reply via email to

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