Re: replace question.
| From: | Jason Granum | Date: | Mon, 11 Sep 2000 14:19:11 +0000 |
| Subject: | Re: replace question. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16181@lists.php.net to get a copy of this message | ||
Thanks :) Thats what I was lookin for :)
On Mon, 11 Sep 2000, Andreas Pour wrote:
> 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);
>
>