Reputation: 37
How would you invert this expression to match everything BUT the contents between the <!-- LIST -->
and <!-- /LIST -->
tags?
((?s)<!-- LIST -->.*?<!-- /LIST -->)
Meaning I'd like to remove everything before <!-- LIST -->
and after <!-- /LIST -->
Upvotes: 1
Views: 58
Reputation: 6272
The regex you have used already matches the section between the two tags, you have to simply add the prior and following sections and use the backreference to replace all the contents with the saved group (usually the slash /
is to escape also).
This is a generic regex code:
s/(?s).*(<!-- LIST -->.*?<!-- \/LIST -->).*/\1/
Implementation online here
Upvotes: 1