Re: ereg_replace help
| From: | Henrik Hudson | Date: | Tue, 18 Nov 2003 07:26:21 +0000 |
| Subject: | Re: ereg_replace help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170067@lists.php.net to get a copy of this message | ||
On Monday 17 November 2003 23:37,
Martin Towell <martin.towell@world.net> sent a missive stating:
> Hi All,
>
> I have an array of strings in the following format:
> "abcd - rst"
> "abcd - uvw"
> "abcd - xyz"
> "foobar - rst"
> "blah - rst"
> "googol - uvw"
>
> What I want to do is strip everything from the " - " bit of the string to
> the end, _but_ only for the strings that don't start with "abcd"
>
> I was thinking something like the following:
> echo ereg_replace("(!abcd) - xyz", "\\1", $str)."\n";
> but obviously this doesn't work, otherwise I wouldn't be emailing the
> list...
>
> Can anyone help? I need to use ereg_replace() because it's part of our code
> library and therefore can't change :(
>
> TIA
> Martin
Possibly have to do a if statement, ereg for the abcd and then if ture, do
your ereg replace? I can't logically think how that would work in one regex,
since you want to match first and then replace...but my regex skills aren't
top notch either :)
Henrik
--
Henrik Hudson
listsNO@SPAMrhavenn.net
"`If there's anything more important than my ego
around, I want it caught and shot now.'"
--Hitchhikers Guide to the Galaxy