How do I regex match everything that is between two strings? The things between two strings span several lines and can contain all html characters too.
For example:
<p>something</p>
<!-- OPTIONAL -->
<p class="sdf"> some text</p>
<p> some other text</p>
<!-- OPTIONAL END -->
<p>The end</p>
I want to strip the whole optional part off. but the greedy any character match isn't doing what I wanted.. the pattern I'm using is
<!-- OPTIONAL -->.*<!-- OPTIONAL END -->
<!-- OPTIONAL -->(.*)<!-- OPTIONAL END -->
<!-- OPTIONAL -->(.*)\s+<!-- OPTIONAL END -->
(?=<!-- OPTIONAL -->)(.*)\s+<!-- OPTIONAL END -->
All of them match the first optional tag, if only the first part is given, but doesn't do well with complete lines.
Here's an example: http://regexr.com?352bk
Thanks