On Fri, Aug 01, 2003 at 05:13:05PM +0200, Marek Kilimajer wrote: > And besides ereg_replace would not work becase it's greedy, .* would > match "going", than "going" would not be found and the whole match would > fail.
nope, it would backtrace then. but the first .* ist greedy so it would match the last hello, not the first one if there is more than one "hello" in the string. > messju mohr wrote: > > >you mean > >$newtext= ereg_replace(".*?(hello.*going).*","\\1",$text); > >?? > > > >i would suggest preg_replace in favour to ereg_replace: > >$newtext= preg_replace("!.*?(hello.*going).*!","$1",$text); > > > >it is more powerfull, faster and widely available. > > > >greetings > >messju > > > > > > > >>echo $newtext; > >>?> > >>........... > >> > >>Thank you. > >>Tony Ritter > >> > >> > >> > >> > >>-- > >>PHP General Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php