Re: Using eregi_replace()
| From: | messju mohr | Date: | Fri, 01 Aug 2003 14:58:50 +0000 |
| Subject: | Re: Using eregi_replace() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-157950@lists.php.net to get a copy of this message | ||
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