By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,730 Members | 1,399 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,730 IT Pros & Developers. It's quick & easy.

Removing some HTML with preg_replace

P: n/a
I need to be able to upload a file (html) to the server and strip away
everything up-to and including the <BODY> tag and everything from
</BODY> down. I have a perl script that does this successfully using
the following 2 lines...
$progress_report =~s/^.*<BODY.*?>//s;
$progress_report =~s/<\/BODY>.*//s;
I want to be able to do this with php. Can anybody help me with this?
I tried using hte regexp above in the preg_replace() function, but it
did not work.

--
Mike
kn*****@cairodurham.org
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
mike wrote:
I need to be able to upload a file (html) to the server and strip away
everything up-to and including the <BODY> tag and everything from
</BODY> down.


For that one needs a parser, not a single regular expression.

--
Jock
Jul 17 '05 #2

P: n/a
"mike" <kn*****@cairodurham.org> wrote in message
news:d5**************************@posting.google.c om...
I need to be able to upload a file (html) to the server and strip away
everything up-to and including the <BODY> tag and everything from
</BODY> down. I have a perl script that does this successfully using
the following 2 lines...
$progress_report =~s/^.*<BODY.*?>//s;
$progress_report =~s/<\/BODY>.*//s;


The same regexps, different syntax:

$progress_report = preg_replace(array('/^.*<BODY.*?>/si', '/<\/BODY>.*/si'),
array('', ''), $progress_report);
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.