title: Multiline regex match for EPL labels
body: <p>EPL label's format looks like this:</p>
  <pre><code>N                      // START OF LABEL 1
  .... EPL CODE ....     // LABEL CODE
  P#                     // END OF LABEL 1, BEING # A NUMBER
  N                      // START OF LABEL 2
  .... EPL CODE ....     // LABEL CODE
  P#                     // END OF LABEL 2, BEING # A NUMBER
                         // EMPTY LINE
  </code></pre>
  <p>I want to split this text into two labels, so I wrote a regular expression: <code>/^N$.+?^P\d$/gsm</code>. And I tested it at <a href="https://regexr.com/6b9gf" rel="nofollow noreferrer">regexr.com</a>.</p>
  <p>Then, I tried to code it into my application but I had no matches. This is my code simplified:</p>
  <pre><code>var epl = &quot;......&quot;; // EPL LABEL TEXT
  var regexPattern = @&quot;^N$.+?^P\d$&quot;;
  var regexOptions = RegexOptions.Singleline | RegexOptions.Multiline;
  var regex = new Regex(regexPattern, regexOptions);
  
  var matches = regex.Matches(epl);
  Console.WriteLine($&quot;Found {matches.Count} matches&quot;);    // -&gt; Found 0 matches
  </code></pre>
  <p>If I replace the regex by <code>@&quot;N.+?P\d&quot;</code> it works, except if P# or N are part of the EPL label code. I can get it to work if I use <code>[\r|\n]+</code> instead of $ and ^ symbols, but I wonder why is this code failing.</p>
  <p>Working pattern by now: <code>@&quot;(N[\r|\n]+)(.+?)([\r|\n]+P\d[\r|\n]+)&quot;</code>. It's valid, but I'd like to get the $ and ^ symbols to work.</p>