Re: question about str_replace function

From: Date: Mon, 08 Jan 2007 13:53:16 +0000
Subject: Re: question about str_replace function
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-246753@lists.php.net to get a copy of this message
# jochem@iamjochem.com / 2007-01-08 11:35:06 +0100: > Dick Jiang wrote: > > I think you'd better use regular expression to replace the word > > agreed - only it a serious dive in the deep end of regexps - the OP may > have to use a negative lookahead assertion, something like: > > $string="avenue 1, ave 1 both have av+e :-)"; > $words = preg_replace("#\\bave(?!nue)#", "avenue", $string); That'll also make "average" into "avenuerage". A word-boundary assertion should (admittedly, I didn't check) be fine on both sides: '#\bave\b#'. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991

« previous php.general (#246753) next »