You are here: Re: [PHP] Regular Expression help « PHP « IT news, forums, messages
Re: [PHP] Regular Expression help

Posted by Chris on 01/19/06 18:27

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация