View Full Version : Simple RegEx Problem

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


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.


10-15-2005, 04: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 );
$tabContent = $eregMatches[1];
/* tabContent has the <table>...</table> stuff in */