Re: Removing all <tr> tag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Binoy AV a écrit :
Hi,
I have an html file containing a table. I applied
eregi("<TR>.*</TR>",$contents,$temp) through my Php.I am getting
> (...)
The code removing only the first and last <(/)tr>.

Expected behaviour : regex are 'greedy', ie the .* matches the longuest string possible

How to do it using eregi ?

Use preg_* functions (Perl regex are more powerfull and faster)

ex (not tested)
$temp = preg_replace('/<tr>(.*?)<\\/tr>/', '$1', $content);

PS the '?' in '.*?' means previous modifier (*) is not greedy
   (Perl re syntax, man perlre)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux