title: Is there a shorter way to pull groups out of a Powershell regex?
body: <p>In PowerShell I find myself doing this kind of thing over and over again for matches:</p>
  
  <pre><code>some-command | select-string '^(//[^#]*)' |
       %{some-other-command $_.matches[0].groups[1].value}
  </code></pre>
  
  <p>So basically - run a command that generates lines of text, and for each line I want to run a command on a regex capture inside the line (if it matches). Seems really simple. The above works, but is there a shorter way to pull out those regex capture groups? Perl had $1 and so on, if I remember right. Posh has to have something similar, right? I've seen "$matches" references on SO but can't figure out what makes that get set.</p>
  
  <p>I'm very new to PowerShell btw, just started learning.</p>