I have the following code from lines 6-20
<div>
1
</div>
<div>
2
</div>
<div>
3
</div>
<div>
4
</div>
<div>
5
</div>
I want to replace all <div> {anything here} </div>
with none.
I tried the following
:%s/<div>\W+.\W+div>//
:6,20s/<div>\W+.\W+div>//
:6,20s/<div>\W+.\W+div>/\0/
:%s/<div>\W+.\W+div>/\0/
Nothing works. It says Pattern not found
But when I search with this
/<div>\W+.\W+div>
It shows that there are 5
matches
How to achieve this substitution?
+
is not a valid metacharacter and will only match a literal+
, so I'm not sure how you're getting 5 matches... This regexp should work:/<div>\_.\{-}<\/div>/
, can you check whether it works for you?