* Thus wrote Martin Towell ([EMAIL PROTECTED]): > 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... >
$newarray = preg_replace('/((?<!abcd) - (.*))$/', '\\3', $array); > Can anyone help? I need to use ereg_replace() because it's part of our code > library and therefore can't change :( How do you mean its part of your code library? I would strongly suggest using preg_* for its speed and capabilites. Curt -- "My PHP key is worn out" PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php