all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Pattern matching on match-string groups #elisp #question
@ 2021-02-25  5:11 Ag Ibragimov
  2021-02-25 14:55 ` Basil L. Contovounesios
  0 siblings, 1 reply; 13+ messages in thread
From: Ag Ibragimov @ 2021-02-25  5:11 UTC (permalink / raw)
  To: emacs-devel


Can someone please tell if it is possible to use pcase-let to dissect groups (parenthesized expressions) of match-string. Here's a dumb example:

(let* ((s "lorem-foo-1-ipsum-bar-21_baz-42")
       (_ (string-match "\\(foo-[0-9]+\\).*\\(bar-[0-9]+\\).*\\(baz-[0-9]+\\)" s))
       (group-1 (match-string 1 s))
       (group-2 (match-string 2 s))
       (group-3 (match-string 3 s)))
  (format "%s-%s-%s" group-1 group-2 group-3)) ;; => "foo-1-bar-21-baz-42"

Is there a more elegant way of retrieving these groups?




^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-02-28 15:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-25  5:11 Pattern matching on match-string groups #elisp #question Ag Ibragimov
2021-02-25 14:55 ` Basil L. Contovounesios
2021-02-25 15:32   ` Stefan Monnier
2021-02-25 18:28     ` Mattias Engdegård
2021-02-26  4:31       ` Stefan Monnier
2021-02-26 10:24         ` Mattias Engdegård
2021-02-26 19:38           ` Stefan Monnier
2021-02-27 10:17             ` Mattias Engdegård
2021-02-27 14:39               ` Stefan Monnier
2021-02-27 18:10                 ` Mattias Engdegård
2021-02-27 20:32                   ` Stefan Monnier
2021-02-28 13:46                     ` Mattias Engdegård
2021-02-28 15:37                       ` Stefan Monnier

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.