all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ag Ibragimov <agzam.ibragimov@gmail.com>
To: emacs-devel@gnu.org
Subject: Pattern matching on match-string groups #elisp #question
Date: Wed, 24 Feb 2021 23:11:04 -0600	[thread overview]
Message-ID: <m2h7m0d95j.fsf@gmail.com> (raw)


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?




             reply	other threads:[~2021-02-25  5:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25  5:11 Ag Ibragimov [this message]
2021-02-25 14:55 ` Pattern matching on match-string groups #elisp #question 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2h7m0d95j.fsf@gmail.com \
    --to=agzam.ibragimov@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.