Reputation: 444
I have about 50 html documents and I need to replace the text between
<!DOCTYPE
and
<!-- start content -->
with
<?php require("header.php"); ?>
From what I've read, Notepad++ does not support multiple line regular expressions but I thought I might put that in the question too. I'm new to regular expressions so I need someone to tell me how to do this. Thanks in advance!
Upvotes: 4
Views: 2742
Reputation: 336128
I have neither Notepad++ nor Textpad installed, so I can't say for sure, but one of the following might work there:
Search for
<!DOCTYPE[\s\S]*?<!-- start content -->
or<!DOCTYPE.*?<!-- start content -->
with the "Dot matches newline" option set or(?s)<!DOCTYPE.*?<!-- start content -->
and replace that with <?php require("header.php"); ?>
.
This will remove everything between the two phrases (including the phrases themselves). If you don't want that (I'm not sure from your question), then you probably want to keep what's on the first line after <!DOCTYPE
, right? So:
Search for (<!DOCTYPE[^\r\n]*)[\s\S]*?<!-- start content -->
(or (?s)(<!DOCTYPE[^\r\n]*).*?<!-- start content -->
etc.),
and replace with $1<?php require("header.php"); ?><!-- start content -->
Upvotes: 1