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