Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
pedrotuga
Forum Contributor
Posts: 249 Joined: Tue Dec 13, 2005 11:08 pm
Post
by pedrotuga » Tue Sep 01, 2009 5:52 pm
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
ridgerunner
Forum Contributor
Posts: 214 Joined: Sun Jul 05, 2009 10:39 pm
Location: SLC, UT
Post
by ridgerunner » Thu Sep 03, 2009 8:56 pm
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.