Connecting Tech Pros Worldwide Help | Site Map

Removing some HTML with preg_replace

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:57 AM
mike
Guest
 
Posts: n/a
Default Removing some HTML with preg_replace

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, 04:57 AM
John Dunlop
Guest
 
Posts: n/a
Default 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, 04:57 AM
Chung Leong
Guest
 
Posts: n/a
Default 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);


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.