Reputation: 27
i have aprox. 200 files with different content in <head> </head>
. I want to replace it and leave it with nothing.
Is there a regular expression for Notepad++ or something like that?
I had this regular expression:
<head>[^<>]+</head>
But for some reason (that i don't know) it doesn't works in these files.
Upvotes: 0
Views: 359
Reputation: 150020
[^<>]+
means to match one or more characters other than <
or >
. That is, the full regular expression that you show is looking for <head>
followed by some non <
and >
characters, followed by </head>
.
But most HTML documents will have a <head>
element that contains <
and >
characters in order to define other elements like <title>
and so forth, so your regex will not match those.
Try this:
<head>.+</head>
I.e., use .+
to match any characters in between the opening <head>
and closing </head>
. Then in Notepad++'s Find/Replace window make sure you've selected the "Regular expression" radio button and ticked the ". matches newline" checkbox. If you also want to match completely empty <head>
elements then change .+
to .*
.
Upvotes: 2