note 36065 added to function.ereg-replace

From: Date: Wed, 24 Sep 2003 16:43:59 +0000
Subject: note 36065 added to function.ereg-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-57055@lists.php.net to get a copy of this message
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.) ---- Manual Page -- http://www.php.net/manual/en/function.ereg-replace.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36065 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36065&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36065&report=yes

« previous php.notes (#57055) next »