We help IT Professionals succeed at work.

PHP Multi Line preg_replace problem

alanpollenz
alanpollenz asked
on
3,412 Views
Last Modified: 2013-12-13
I am attempting to trim the starting html tags from an html file.  A shortened version of the  original file looks like this:

==============================================================

<HTML>
<HEAD>
<TITLE>Team Manager Individual Meet Results by Name</TITLE>
</HEAD>
<BODY>
<TABLE ALIGN=BLEEDLEFT WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=1.053%></TD>
<TD WIDTH=1.053%></TD>
<TD WIDTH=1.053%></TD>
<TD WIDTH=1.053%></TD>
<TD WIDTH=2.105%></TD>
</TR>
</TABLE>
</BODY>
</HTML>
==============================================================

I need to remove the:

<HTML>
<HEAD>
<TITLE>Team Manager Individual Meet Results by Name</TITLE>
</HEAD>
<BODY>

and

</BODY>
</HTML>

using php's preg_replace function.  I cannot use str_replace, at least at the top, because what is between the TITLE tags may change.

I have tried  $meet_result=preg_replace("/<HTML>.*(^[<BODY>]$)/i","",$meet_result); (where $meet_result is the code above) to remove everything before the opening table tag, but this does not work.

Any ideas?
Comment
Watch Question

Top Expert 2007
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.