regexp magic

From: Date: Tue, 28 May 2002 23:56:03 +0000
Subject: regexp magic
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-99592@lists.php.net to get a copy of this message
Greetings everyone, I'm trying to do some regexp magic and just can't seem to get it done with PHP. Basically I want to evaluate a word and if the last character of the word is an 's', to knock it off, unless there are two consecutives at the end of the word. So 'boys' would become 'boy' and 'cars' would become 'car' However, I don't want 'happiness' to become 'happines', so I need to stop it where there are two consecutive 'ss' on the end of the word. $out=eregi_replace("[s]$",'',$in); will knock off the last one. I thought about: $out=eregi_replace("[^s][s]$",'',$in); but that won't work.... any ideas? thanks

« previous php.general (#99592) next »