Connecting Tech Pros Worldwide Help | Site Map

Removing some HTML with preg_replace

  #1  
Old July 17th, 2005, 05:57 AM
mike
Guest
 
Posts: 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
knichel@cairodurham.org
  #2  
Old July 17th, 2005, 05:57 AM
John Dunlop
Guest
 
Posts: n/a

re: Removing some HTML with preg_replace


mike wrote:
[color=blue]
> 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.[/color]

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

--
Jock
  #3  
Old July 17th, 2005, 05:57 AM
Chung Leong
Guest
 
Posts: n/a

re: Removing some HTML with preg_replace


"mike" <knichel@cairodurham.org> wrote in message
news:d5b2d8a3.0404230656.74fd69ae@posting.google.c om...[color=blue]
> 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;
>[/color]

The same regexps, different syntax:

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


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with mod_rewrite and replacing spaces in URL David answers 2 October 18th, 2006 06:45 PM
Help removing a simple space vbMark answers 2 September 20th, 2005 05:25 PM
Removing html anchors from POST'ed text string Dariusz answers 1 July 17th, 2005 06:02 AM