If you use Rails, Use classify
. It handles edge cases well.
"app_user".classify # => AppUser
"user_links".classify # => UserLink
Note:
This answer is specific to the description given in the question(it is not specific to the question title). If one is trying to convert a string to camel-case they should use Sergio's answer. The questioner states that he wants to convert app_user
to AppUser
(not App_user
), hence this answer..