title: Powershell: Regex matching with Get-content -Raw flag results in empty results
body: <p><em><strong>Solution was adding (?ms) to the front of my regex query</strong></em></p>
  <p>I am trying to search for chunks of text within a file, and preserving the line breaks in a chunk.</p>
  <p>When I define my variable as <code>$variable = get-content $fromfile</code>,
  my function (below) is able to find the text I'm looking for but it is difficult to parse further due to a lack of line breaks</p>
  <pre><code>function FindBetween($first, $second, $importing){
  
      $pattern = &quot;$first(.*?)$second&quot;
      
      $result = [regex]::Match($importing, $pattern).Groups[1].Value
  
      return $result
  }
  </code></pre>
  <p>when I define my variable as <code>$variable = get-content $fromfile -raw</code>, the output of my query is blank. I'm able to print the variable, and it does preserve the line breaks.
  <br><br></p>
  <p>I run into the same issue regardless of if I add <code>\r\n</code> to the end of my pattern, if I use <code>@()</code> around my variable definition, if I use <code>-Delimiter \n</code>, or any combination of all those.</p>
  <p>Whole code is here:</p>
  <pre><code>param($fromfile)
  
  $working = get-content $fromfile -raw
  
  function FindBetween($first, $second, $importing){
  
      $pattern = &quot;(?ms)$first(.*?)$second&quot;
      
      $result = [regex]::Match($importing, $pattern).Groups[1].Value
      #$result = select-string -InputObject $importing -Pattern $pattern
  
      return $result
  }
  
  
  FindBetween -first &quot;host ####&quot; -second &quot;#### flag 2&quot; -importing $working | Out-File &quot;testresult.txt&quot;
  </code></pre>
  <p>the file I'm testing it against looks like:</p>
  <pre><code>#### flag 1 host ####
  
  stuff in between
  
  #### flag 2 server ####
  
  #### process manager ####
  </code></pre>
  <p><br><br>
  As to why I'm doing this:<br>
  I'm trying to automate taking a file that has defined sections with titles and outputting the content of those separate sections into a .csv (each section is formatted drastically different from each other). These files are all uniform to each other, containing the same sections and general content.</p>