title: Replacing a Matched Character in Powershell
body: <p>I have a text file of 3 name entries:</p>
  <pre><code># dot_test.txt
  001 AALTON, Alan .....25 Every Street
  006 JOHNS, Jason .... 3 Steep Street
  002 BROWN. James .... 101 Browns Road
  </code></pre>
  <p>My task is to find instances of NAME. when it should be NAME, using the following:</p>
  <pre><code>Select-String -AllMatches -Path $input_path -Pattern '(?s)[A-Z]{3}.*?\D(?=\s|$)' -CaseSensitive |
      ForEach-Object { if($_.Matches.Value -match '\.$'){$_.Matches.Value -replace '\,$'} }
  </code></pre>
  <p>The output is:</p>
  <pre><code>BROWN.
  </code></pre>
  <p>The conclusion is this script block identifies the instance of NAME. but fails to make the replacement.</p>
  <p>Any suggestions on how to achieve this would be appreciated.</p>