title: -Replace and regex in powershell
body: <p>I am trying to find a way to replace the same string with different values in a text file using powershell. The word is the same with special characters (e.g &quot;<strong>[Placeholder]</strong>&quot;). This is for a .json file that looks something similar to this.</p>
  <pre><code>Line1: 
  Line2:
  Line3: [Placeholder]
  Line4:  [Placeholder]
  </code></pre>
  <p>The idea is to change the string [Placeholder] on line 3 with the version and line 4 with the current date. When i try to do this with the following code it automatically replaces both [Placeholder]'s with the version and i am struggling to find a way to have line 3 be the version and 4 the date</p>
  <pre><code>$currentVersion = &quot;v.1.2.3.4&quot;
  $currentDate =  &quot;08/08/2021&quot;
  $original_file = 'C:\Users\samue\Desktop\D\V1\hehehehe.txt'
  (Get-Content $original_file) | Foreach-Object {
      $_ -replace ([regex]::Escape('[Placeholder]')), $currentVersion `
        -replace ([regex]::Escape('[Placeholder]')), $currentDate
      } | Set-Content $original_file
   
  </code></pre>
  <p>As you can see it will replace all [placeholder]'s with $currentVersion because that is the first thing it finds but I need some help on maybe how to use regex to match and then replace the word</p>
  <pre><code>Line1: 
  Line2:
  Line3: v.1.2.3.4
  Line4:  v.1.2.3.4
  </code></pre>