note 33606 deleted from function.eregi-replace by alindeman

From: Date: Tue, 01 Jul 2003 20:10:01 +0000
Subject: note 33606 deleted from function.eregi-replace by alindeman
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-51312@lists.php.net to get a copy of this message
Note Submitter: matthew@tellstar.freeserve.co.uk ---- 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'.

« previous php.notes (#51312) next »