Re: replace question.

From: Date: Mon, 11 Sep 2000 14:07:19 +0000
Subject: Re: replace question.
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-16180@lists.php.net to get a copy of this message
Andreas Pour wrote: > > Jason Granum wrote: > > > > I'm trying to do an ereg_replace however I only want to replace the 1st > > match in the text, not every match. I've scoured through the manual but > > can't figure anything out. Basicly I'm looking for the equivilent to > > Perls s/find/replace/; not s/find/replace/g; -- Thanks for any help > > Off the top of my head . . . how about > > preg_replace("@^(.*?)($regex)(.*)$@", "\1$replace\2", $string); ^3 oops: preg_replace("@^(.*?)($regex)(.*)$@", "\\1$replace\\3", $string);

« previous php.general (#16180) next »