I'd like to define a function to do a query-replace-regexp
with a pattern I often use. When not using capture groups, it works:
(defun my-replace ()
(interactive)
(query-replace-regexp "[[:nonascii:][:ascii:]]*xxx" "replacedText" nil (point-min) (point-max)))
But I couldn't figure out how to use capture groups -- neither '\(\)' nor '()' works:
(defun my-replace ()
(interactive)
(query-replace-regexp "([[:nonascii:][:ascii:]]*)xxx" "\1replacedText" nil (point-min) (point-max)))
(defun my-replace ()
(interactive)
(query-replace-regexp "\([[:nonascii:][:ascii:]]*\)xxx" "\1replacedText" nil (point-min) (point-max)))
But when invoked with M-x query-replace-regexp
, \([[:nonascii:][:ascii:]]*\)xxx
would work.