On Fri, Aug 01, 2003 at 10:33:50AM -0400, Anthony Ritter wrote: > Using eregi_replace(), is there a way to take out a piece of a sentence - > which has spaces - and then return the new sentence? > > For example, to return the new sentence: > > hello I must be going > > from the original sentence: > > blah blah blah hello I must be going blah blah. > > I tried: > ................... > <? > $text="blah blah blah hello I must be going blah blah"; > $text= eregi_replace("(hello.)(.going)","$newtext",$text);
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