|
Posted by Rik on 07/05/06 10:05
trihanhcie@gmail.com wrote:
> It can be :
> <td> text1 </td>
> or
> <td>
> text1
> </td>
> or anything else
>
> eregi("<td(.*)>(.*)(</td>?)",$text,$regtext);
---------------------------^
This doesn't do what you think it does
> The problem is that, if I have
> <td> text</td>
> <td>text2</td>
>
> regtext will return text</td><td>text2.
>
> How can I change the expression so that it stops at the first
> occurence of </td>?
An asterisk (*) can made non-greedy (i.e. capturing untill the next match is
true) by placing a question mark after it.
preg_match_all('|<td[^>]*>(.*?)</td>|i',$text,$matches);
Grtz,
--
Rik Wasmus
[Back to original message]
|