However, this works using: preg_replace() .....................
<? $text="blah blah blah hello I must be going blah blah"; $newtext= preg_replace("!.*?(hello.*going).*!","$1",$text); echo $newtext; ?> ................ Thank you all. Is there a way I can be sure of the syntax? "!.*?(hello.*going).*!", // the pattern which - I think - reads as follows: !.*? // do not use any character or characters before the grouping of hello (hello.*going) // get the grouping of hello and any character after that word to going .*! // do not use any character or characters after the grouping of going - not sure why the exclamation is at the end if it is a negation symbol. Please advise. Thank you. TR "$1", // the grouping $text // the original string -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php