title: Using RegEx matches with PowerShell
body: <p>I have a massive library of music, in which I am using PowerShell/RegEx to find particular songs. I am having trouble finding only the exact artist I need. For example, this code:</p>
  <pre><code>$artist = &quot;Paul Young&quot;
  $allsongsRAW = Get-ChildItem -Path &quot;C:\Music&quot; -Recurse | Where-Object {$_.Extension -eq &quot;.mp3&quot;}
  ($allsongsRAW -match &quot;(\s*$artist\s(-|\W)\s*)&quot; | Sort-Object {Get-Random}).Name
  </code></pre>
  <p>Returns:</p>
  <pre class="lang-none prettyprint-override"><code>Paul Young - Everything Must Change.mp3
  Paul Young - Come Back And Stay.mp3
  Paul Young - Everytime You Go Away.mp3
  John Paul Young - Love Is In The Air.mp3
  Paul Young - Wherever I Lay My Hat (That's My Home).mp3
  Paul Young - What Becomes Of The Brokenhearted.mp3
  Paul Young - Love of the Common People.mp3
  </code></pre>
  <p>And this code:</p>
  <pre><code>$artist = &quot;Queen&quot;
  $allsongsRAW = Get-ChildItem -Path &quot;C:\Music&quot; -Recurse | Where-Object {$_.Extension -eq &quot;.mp3&quot;}
  ($allsongsRAW -match &quot;(\s*$artist\s(-|\W)\s*)&quot; | Sort-Object {Get-Random}).Name
  </code></pre>
  <p>Returns:</p>
  <pre class="lang-none prettyprint-override"><code>Storm Queen - Look Right Through (Jamie Jones Remix).mp3
  Queen - The Invisible Man.mp3
  Queen - Don't Stop Me Now.mp3
  Storm Queen - Look Right Through (MK Dub III).mp3
  Queen - Bohemian Rhapsody.mp3
  Queen - I'm In Love With My Car.mp3
  Queen - One Vision.mp3
  Queen - A Kind Of Magic.mp3
  Queen - Radio Ga Ga.mp3
  Queen - Killer Queen.mp3
  Queen - You're My Best Friend.mp3
  Queen - Fat Bottomed Girls.mp3
  Queen - Headlong.mp3
  Queen - I Want It All.mp3
  Queen - Somebody To Love.mp3
  Queen - Bicycle Race.mp3
  Queen - Crazy little thing called love.mp3
  Queen - Body Language.mp3
  Queen - Another One Bites The Dust.mp3
  Queen - We Are The Champions.mp3
  Queen - Tie Your Mother Down.mp3
  Queen - Under Pressure.mp3
  Queen - We Will Rock You.mp3
  Queen - I Want To Break Free.mp3
  Queen - Flash.mp3
  Queen - Fight From The Inside.mp3
  </code></pre>
  <p>As you can see, the Regular Expression I am using is picking up other Artists with a similar name, especially artists with other names proceeding the search criteria.</p>
  <p>How can I tweak the RegEx to only display the artist I need?</p>