PHP List,
Recently I wrote a piece of code to scrape data from an HTML page.
Part of that code deleted all the unwanted text from the very top of the
page, where it says "<!DOCTYPE", all the way down to the first instance
of a "<ul>" tag.
That code looks like this:
ereg_replace("<!DOCTYPE(.*)<ul>", "", $htmlPage);
It works fine. But I noticed that on almost all the tutorial pages I
looked at, they just about always used preg_replace, and not ereg_replace.
It seemed that the main difference was that preg_replace required
forward slashes around the regular expression, like so:
preg_replace("/<!DOCTYPE(.*)<ul>/", "", $htmlPage);
But that didn't work, and returned an error.
Since ereg was working, though, I figured I would just stick with it.
Still, I thought it worth asking:
Is there any reason why either ereg or preg would be more desirable over
the other?
Why does the ereg work for the command above, but preg not?
Thank you for any advice.
--
Dave M G
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php