Thread: RegExp

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    54
    Rep Power
    13

    RegExp


    For a string of the formats: abc_def_ghl or abcd_xyz, abc_def_ghl_k, etc

    I like to replace the "_char" with the uppercased char, for example:

    abc_def_ghl --> abcDefGhl

    abcd_xyz --> abcdXyz

    abc_def_ghl_k --> abcDefGhlK

    etc.

    What is the RegExp for it?


    Thanks
  2. #2
  3. Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Location
    London, UK
    Posts
    4,004
    Rep Power
    2794
    Moving to the Regular Expression forums.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1017
    Hi,

    well, the regex will be very simple. If you only have letters from a to z, it's
    Code:
    _([a-z])
    with the letter being in the first matching group (hence the parentheses).

    Replacing the string with the uppercase letter is up to the application (whatever language you're using).

    Comments on this post

    • ishnid agrees

IMN logo majestic logo threadwatch logo seochat tools logo