minibuffer

How to replace regexp matches in a string in Emacs Lisp?

October 11, 2023
"^^^foo-bar^^^foo-bar" ----> "^^^bar_foo^^^bar_foo"

(replace-regexp-in-string "\\(foo\\)-\\(bar\\)" "\\2_\\1" "^^^foo-bar^^^foo-bar")
;; "^^^bar_foo^^^bar_foo"