Re: The difference between ereg and preg?
| From: | Dave M G | Date: | Fri, 04 Aug 2006 10:30:09 +0000 |
| Subject: | Re: The difference between ereg and preg? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-240099@lists.php.net to get a copy of this message | ||
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