Quote:
Originally Posted by dansgalaxy
PHP Code:
$pattern = "#\<table\>(.+?)</table\>#ie";
|
To begin with, a couple of minor issues: first, the brackets (< and >) don't need to be escaped. It won't break your regexp if you do use them, though. Second, the "e" modifier at the end of the pattern is ignored for a preg_match(). I can't remember what it does, but I do know it's only used for preg_replace().
By default, in preg_whatever functions, a . will match all characters EXCEPT newlines. So if this table that you are trying to scrape has a newline anywhere in it, this regexp will not match it. The solution is to add the "s" modifier to the end of the pattern.
Try:
PHP Code:
$pattern = "#<table>(.+?)</table>#is";
Hopefully that fixes it.
EDIT: I'm going to sneak an edit in here because I just realized that the brackets (< and >) can have a special meaning in regex, and I don't want someone to read this later and leave with false info. Regex is so complicated!
Last edited by frost : 07-01-2008 at 01:45 AM.
Reason: Factual mistake. Oops.
|