title: Multiline Regex in PowerShell
body: <p>I have this PowerShell script that's main purpose is to search through HTML files within a folder, find specific HTML markup, and replace with what I tell it to.</p>
  
  <p>I have been able to do 3/4 of my find and replaces perfectly. The one I am having trouble with involves a Regular Expression.</p>
  
  <p>This is the markup that I am trying to make my regex find and replace:</p>
  
  <pre><code>&lt;a href="programsactivities_skating.html"&gt;&lt;br /&gt;
                                             &lt;/a&gt;
  </code></pre>
  
  <p>Here is the regex I have so far, along with the function I am using it in:</p>
  
  <pre><code>automate -school "C:\Users\$env:username\Desktop\schools\$question" -query '(?mis)(?!exclude1|exclude2|exclude3)(&lt;a[^&gt;]*?&gt;(\s|&amp;nbsp;|&lt;br\s?/?&gt;)*&lt;/a&gt;)' -replace ''
  </code></pre>
  
  <p>And here is the automate function:</p>
  
  <pre><code>function automate($school, $query, $replace) {
      $processFiles = Get-ChildItem -Exclude *.bak -Include "*.html", "*.HTML", "*.htm", "*.HTM" -Recurse -Path $school
      foreach ($file in  $processFiles) {
          $text = Get-Content $file
          $text = $text -replace $query, $replace
          $text | Out-File $file -Force -Encoding utf8
      }
  }
  </code></pre>
  
  <p>I have been trying to figure out the solution to this for about 2 days now, and just can't seem to get it to work. I have determined that problem is that I need to tell my regex to account for Multiline, and that's what I'm having trouble with.</p>
  
  <p>Any help anyone can provide is greatly appreciate.</p>
  
  <p>Thanks in Advance.</p>