Re: Using eregi_replace()
| From: | Anthony Ritter | Date: | Fri, 01 Aug 2003 15:36:29 +0000 |
| Subject: | Re: Using eregi_replace() | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157966@lists.php.net to get a copy of this message | ||
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