note 36065 deleted from function.ereg-replace by didou
| From: | didou@php.net | Date: | Wed, 24 Sep 2003 17:16:20 +0000 |
| Subject: | note 36065 deleted from function.ereg-replace by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57058@lists.php.net to get a copy of this message | ||
Note Submitter: the_mindflayer_ (upon) operamail.com
----
Not to spoil Alex's (devnull at hotmail dot com) fun, but...
Even at first glance, his link-remover isn't very robust. It corrupts <a name...> tags
by removing the closing tag. It also corrupts hyperlinks (the same way) when the properties are a
different order or extra whitespace is added between the A and HREF.
He also appears to use the perl non-greedy modifier "?" where it's not needed,
although I'd have to look closer at that.
I don't have time to write out working code for you, but you'd probably want to do
SOMETHING like this one-liner:
/* THIS IS PROBABLY BUGGY!!! */
/* USE THIS CODE *ONLY* AS A START TO WRITING YOUR OWN */
$data=preg_replace("'<a[^>]*>(.*?)</a[^>]*>'si",
"\\1",$data);
Lastly, why IS Alex putting a preg_replace example on the ereg_replace page?
(Yes, my e-mail address has two underscores, total.)