title: Using Powershell to replace string to end of line
body: <p>I need to replace a tag in an ini file for a number of files beginning with news_* using Powershell. I wrote a script to find the tag, but do not know how to replace everything from the tag to the end of the line.</p>
  
  <p>for example if the ini file has:</p>
  
  <pre><code>[tag1] = A string
  [tag2] = 1234567
  [tag3] = Another string
  </code></pre>
  
  <p>And I want to replace all tag 2's with a blank string, I wrote:</p>
  
  <pre><code>$configFiles = Get-ChildItem . news* -rec
  foreach ($file in $configFiles)
  {
      (Get-Content $file.PSPath) |
      Foreach-Object { $_ -replace '[tag2] = ".*?"', '[tag2] = ' } |
      Set-Content $file.PSPath
  }
  </code></pre>
  
  <p>Can you tell me what is wrong with this script?</p>
  
  <p>Thanks!</p>