emacs-devel
[Top][All Lists]
Advanced

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

Pattern matching on match-string groups #elisp #question


From: Ag Ibragimov
Subject: Pattern matching on match-string groups #elisp #question
Date: Wed, 24 Feb 2021 23:11:04 -0600
User-agent: mu4e 1.4.15; emacs 28.0.50


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 via email to

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