Re: Regular Expression help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Boget 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.



Any help would be greatly appreciated!



thnx,
Chris


Those two had valid ones as well, but I like the negative look-behind assertion:

preg_replace('/(?<!^)([A-Z])/','_$1','JimJoeBobBriggs');

Chris

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux