Reputation: 75
How to match text between these tags ?
<!-- |IFNOT:ARCHIVE_PAGE| -->
some text
<!-- |END:IF| -->
Thanx!
Upvotes: 0
Views: 2001
Reputation: 21
preg_replace("/<body>([\s\S]*.*)<\/body>/",$replace,$origional);
this will replace whole content between body tags.
Upvotes: 2
Reputation: 4774
Using Perl, the only special character here is the pipe '|'. So, the following regex will match (and return due to the capturing brackets (.+) ) the text you are looking for:
{<!-- \|IFNOT:ARCHIVE_PAGE\| -->\s*(.+)\s*<!-- \|END:IF\| -->}s
Note that the 's' modifier let's the regex match multiple lines, and the \s* before and after the capturing brackets means that whitespace (including line breaks) will not be included in the returned match.
Upvotes: 0
Reputation: 6948
try this regex:
(?<=<!-- \|IFNOT:ARCHIVE_PAGE\| -->)(\s|.)*?(?=<!-- \|END:IF\| -->)
Upvotes: 1
Reputation: 305
This is not very recommendable but
<!-- \|IFNOT:ARCHIVE_PAGE\| -->((\s|.)*?)<!-- \|END:IF\| -->
Upvotes: 2