note 33606 added to function.eregi-replace

From: Date: Tue, 01 Jul 2003 19:49:27 +0000
Subject: note 33606 added to function.eregi-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-51311@lists.php.net to get a copy of this message
Having found one match in a search string eregi_replace does not look for further matches in that string. If you were to use: $string = "crap crap crap scrapbook crap"; $output = eregi_replace ("[[:space:]]+crap[[:space:]]+", "REMOVED", $string); echo $output; you would get: "crap REMOVED crap scrapbook crap" as your output only the second 'crap' is replaced, although the third meets the search parameter too (the first and last are not surrounded by spaces and so are not replaced anyway). I do not know of a work around for this shortcoming apart from using stri_replace which DOES find all matches within a string, but is not always appropriate, as above where it would also edit out the middle of the word 'scrapbook'. ---- Manual Page -- http://www.php.net/manual/en/function.eregi-replace.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33606 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33606&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33606&report=yes

« previous php.notes (#51311) next »