title: Emacs query-replace with textual transformation
body: <p>I want to find any text in a file that matches a regexp of the form <em>t</em><code>[A-Z]</code><em>u</em> (i.e., a match <em>t</em> followed by a capital letter and another match <em>u</em>, and transform the matched text so that the capital letter is lowercase. For example, for the regexp <code>x[A-Z]y</code></p>
  
  <pre><code>xAy
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>xay
  </code></pre>
  
  <p>and</p>
  
  <pre><code>xZy
  </code></pre>
  
  <p>becomes</p>
  
  <pre><code>xzy
  </code></pre>
  
  <p>Emacs' <code>query-replace</code> 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?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>@Marcel Levy has it: <code>\,</code> in a replacement expression introduces an (arbitrary?) Elisp expression. E.g., the solution to the above is</p>
  
  <pre><code>M-x replace-regexp &lt;RET&gt; x\([A-Z]\)z &lt;RET&gt; x\,(downcase \1)z
  </code></pre>