title: '$null =' in powershell
body: <p>I saw this Powershell statement in a recent <a href="http://www.hanselman.com/blog/UnixFightSedGrepAwkCutAndPullingGroupsOutOfAPowerShellRegularExpressionCapture.aspx" rel="noreferrer">Hanselminutes post</a> -</p>
  
  <pre><code>cat test.txt | foreach-object {$null = $_ -match '&lt;FancyPants&gt;(?&lt;x&gt;.*)&lt;.FancyPants&gt;'; $matches.x} | sort | get-unique
  </code></pre>
  
  <p>I'm trying to learn Powershell at the moment and I think that I understand most of what is going on -</p>
  
  <ul>
  <li>The statement loops through each line of 'test.txt' and runs a regex against the current line</li>
  <li>All the results are collated and then sorted and duplicates removed</li>
  </ul>
  
  <p>My understanding seems to fall down on this part of the statement - </p>
  
  <pre><code>$null = $_ -match '&lt;FancyPants&gt;(?&lt;x&gt;.*)&lt;.FancyPants&gt;'; $matches.x
  </code></pre>
  
  <ul>
  <li>What is the '<code>$null =</code> ' part of the code doing,  I suspect this is
  to handle a scenario when no match is returned but I'm not sure how
  it works? </li>
  <li>Is '<code>$matches.x</code>' returning the matches found?</li>
  </ul>