title: How to reference captures in bash regex replacement
body: <p>How can I include the regex match in the replacement expression in BASH?</p>
  
  <p>Non-working example:</p>
  
  <pre><code>#!/bin/bash
  name=joshua
  echo ${name//[oa]/X\1}
  </code></pre>
  
  <p>I expect to output <code>jXoshuXa</code> with <code>\1</code> being replaced by the matched character.</p>
  
  <p>This doesn't actually work though and outputs <code>jX1shuX1</code> instead.</p>