Re: The difference between ereg and preg?

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

 



Jochem,

Thank you for responding.


does this one work?:
preg_replace('#^<\!DOCTYPE(.*)<ul[^>]*>#is', '', $htmlPage);

Yes, that works. I don't think I would have every figured that out on my own - it's certainly much more complicated than the ereg equivalent.

If I may push for just one more example of how to properly use regular expressions with preg:

It occurs to me that I've been assuming that with regular expressions I could only remove or change specified text.

What if I wanted to get rid of everything *other* than the specified text?

Can I form an expression that would take $htmlPage and delete everything *except* text that is between a <li> tag and a <br> tag?

Or is that something that requires much more than a single use of preg_replace?

--
Dave M G

--
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