I want to find any text in a file that matches a regexp of the form t[A-Z]
u (i.e., a match t followed by a capital letter and another match u, and transform the matched text so that the capital letter is lowercase. For example, for the regexp x[A-Z]y
xAy
becomes
xay
and
xZy
becomes
xzy
Emacs' query-replace
function allows back-references, but AFAIK not the transformation of the matched text. Is there a built-in function that does this? Does anybody have a short Elisp function I could use?
[UPDATE] @Marcel Levy has it: \,
in a replacement expression introduces an (arbitrary?) Elisp expression. E.g., the solution to the above is
M-x replace-regexp <RET> x\([A-Z]\)z <RET> x\,(downcase \1)z