title: How do you extract the value of a regex backreference/match in Powershell
body: <p>I have a text file containing lines of data. I can use the following powershell script to extract the lines I'm interested in:</p>
  
  <pre><code>select-string -path *.txt -pattern "subject=([A-Z\.]+),"
  </code></pre>
  
  <p>Some example data would be:</p>
  
  <pre><code>blah blah subject=THIS.IS.TEST.DATA, blah blah blah
  </code></pre>
  
  <p>What I want is to be able to extract just the actual contents of the subject (i.e. the "THIS.IS.TEST.DATA" string). I tried this:</p>
  
  <pre><code>select-string -path *.txt -pattern "subject=([A-Z\.]+)," | %{ $_.Matches[0] }
  </code></pre>
  
  <p>But the "Matches" property is always null. What am I doing wrong?</p>