Re: preg_match_all()
| From: | Tom Rogers | Date: | Thu, 03 Apr 2003 13:25:35 +0000 |
| Subject: | Re: preg_match_all() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142127@lists.php.net to get a copy of this message | ||
Hi,
Thursday, April 3, 2003, 11:33:02 PM, you wrote:
TJ> I am having problems with preg_match_all spanning over newlines.
TJ> Using /m does not seem to ignore the the newlines.
TJ> // This works
TJ> // Both contents inside <td> and </td> are found
TJ> $html = '<tr valign="top">
TJ> <td width="10">One cell</td>
TJ> <td>Another</td>
TJ> </tr>';
TJ> // This does not
TJ> // Only the contents inside the first <td> and </td> are found
TJ> // The only difference is that there is a linebreak efter the second <td>
TJ> $html = '<tr valign="top">
TJ> <td width="10">One cell</td>
TJ> <td>
TJ> Another</td>
TJ> </tr>';
TJ> preg_match_all("/<td.*>(.*)<\/td>/m", $html, $out);
TJ> I have been doing this before, but I can't remember how I got it working...
TJ> Any thougts?
I think you need /s to cope with newlines
--
regards,
Tom