$strIn = str_replace("/.?<TABLE/i", "<table", $strIn);
$strIn = str_replace("/?<\/table>
$/i", "</table>", $strIn);
preg_match_all("/<TABLE.?>?(<\/TABLE>)/i", $strIn, $arrMatch);
echo '<BR>Number of matches: ' . count($arrMatch);

The above snippet is from my application that is attempting to parse a file for the tables that are within it.

It has three issues that I know of.
1 - The coding upto the first <table> tag does not get removed.
2 - The coding after the last </table> tag does not get removed.

3 - The most important issue is that $arrMatch does not contain the contents of the match.

I believe my problems are related to the regx. Any help would be most extremely welcome.

Thank you
Shaun

    1. It's because you're using str_replace instead of preg_replace. str_replace does not handle regexps
    2. Same as above.
    3. In the middle, it should be .? instead of >? coz right now it's looking for multiple '>' characters.

    Diego

      Write a Reply...