Thread: RegExp

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

    Join Date
    Nov 2005
    Posts
    52
    Rep Power
    9

    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. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    Moving to the Regular Expression forums.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    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