79313429

Date: 2024-12-28 08:13:29
Score: 2
Natty:
Report link

According to @Drew suggestion save-match-data give an all new match-data just as I wanted:

foo-bar-baz

(progn
  (save-match-data
    (goto-char (point-min))
    (re-search-forward "^foo-\\(.*\\)-baz" nil t)
    (message "step 1: %S" (match-string-no-properties 1))) 
;; => step 1 : "bar"

  (save-match-data
    (goto-char (point-min))
    (re-search-forward "^baz-\\(.*\\)-foo" nil t)
    (message "step 2: %S" (match-string-no-properties 1))) 
;; => step 2: no nil
  )
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @Drew
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Thomas Labbé