title: Assign variable value dynamically to Regex captured string
body: <p>I'm trying to cobble togther a simple templating functionality with PowerShell.</p>
  
  <p>So I have this text from a file or DB</p>
  
  <pre><code>$text = "Dear [PERSON], you have been chosen for a special award my the Management of [COMPANY]"
  $PERSON = 'Ahmadu Samuel'
  $COMPANY = 'SuperGlobal Limited'
  </code></pre>
  
  <p>I am trying to use the second capturing parenthesis (which retrieves 'PERSON'), then <code>Get-Variable</code> to retrieve the value of the variable <code>$PERSON</code>, like so:</p>
  
  <pre><code>$content = $txt -replace '([\{\[](\w+)[\}\]])', (gv '$2').value
  </code></pre>
  
  <p>Now, <code>(gv 'PERSON').Value</code> correctly produces <code>Ahmadu Samuel</code>. But with the above, I get an error like this:</p>
  
  <pre><code>gv : Cannot find a variable with the name '$2'
  </code></pre>
  
  <p>Shouldn't <code>(gv '$2').Value</code> do likewise? If not, how can I manipulate this expression to dynamically assign the variable value to this captured string?</p>