alanpollenz
asked on
PHP Multi Line preg_replace problem
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_resul t); (where $meet_result is the code above) to remove everything before the opening table tag, but this does not work.
Any ideas?
==========================
<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(
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.