Page 1 of 1

troubles matching multiline HTML chunk

Posted: Tue Sep 01, 2009 5:52 pm
by pedrotuga
I want to match this:

Code: Select all

 
<!-- THE BEGINNING -->
<div class="whatever">
<p>Some <u>Random</u> HTML in here</p>
</div>
<!-- THE END -->
 
This is the regex i thought of but it doesn't match anything... why?

Code: Select all

|<!--\sTHE\sBEGINNING\s-->.*?<!--\sTHE\sEND\s-->|m

Re: troubles matching multiline HTML chunk

Posted: Thu Sep 03, 2009 8:56 pm
by ridgerunner
Because you need to set the 's' single-line mode, or "dot matches newline mode". The 'm' multi-line mode only affects how the '^' and '$' match or don't match at newlines. Otherwise your regex looks just fine.