...

View Full Version : Simple RegEx Problem



Jak-S
10-15-2005, 03:02 PM
*** Dont worry, i worked it out, cheers *** :)

Hi,

Im new to using regular expressions in PHP, and kinda confused about what all the different functions do. But basically, i have the conents of an HTML file in variable called $input and i need a function and expression that will find the position of the first TABLE tag in that string.

Infact the end result needs to be a string with just the table in, everything from <table.....> to </table>. If there is an even easier way to do this it would be great.

Thanks in advance.

Jack

cdc08x
10-15-2005, 03:59 PM
Just try something like this:


/* I suppose $htmlString is a string with your whole HTML file */
$eregMatches = array();
$found = eregi( '(<table>(.+)</table>)' , $htmlString , $eregMatches );
if($found)
$tabContent = $eregMatches[1];
/* tabContent has the <table>...</table> stuff in */



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum