Re: Regular Expression help

From: Date: Thu, 19 Jan 2006 16:22:24 +0000
Subject: Re: Regular Expression help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-228835@lists.php.net to get a copy of this message
On 1/19/06, Chris Boget <chris.boget@wild.net> wrote: > I've been beating my head against the wall for a while trying to come up > with the RE I need to use. I have a camel case word - let's use > JimJoeBobBriggs. I need to come up with a RE that will fine all the > upper case characters and insert an underscore prior to those characters > with the exception of a possible first character. So using the > aforementioned word, the RE would change it to Jim_Joe_Bob_Briggs. > <?php $string = 'JimJoeBobBriggs''; print preg_replace('/([[:alnum:]])([[:upper:]])/', '\1_\2', $string); ?>

« previous php.general (#228835) next »