Languages
[Edit]
EN

Regex - convert from underscore to camel case notation

8 points
Created by:
AnnLen
9180

To convert from underscore to camel case notation we can use below regex.

Regex:
_([a-z0-9])

Replace with:
\U$1

// BEFORE:
db_column_name

// AFTER:
dbColumnName

Tested with notepad++.

Notes:

  • ensure to have 'Regular expression' radio button checked.

Motivation:
     Why I like to use it?

  • Because I don't need to convert SQL field names manually and it saves my time.
  • I usually use it to when creating java entity and need to convert more then 3 fields from mysql underscore notation (really handy).

Screenshots

Screenshot before:

Regex to convert from underscore to camel case notation - before replace
Regex to convert from underscore to camel case notation - before replace

Screenshot after:

Regex to convert from underscore to camel case notation - after replace
Regex to convert from underscore to camel case notation - after replace

More complex example

// BEFORE:
picture_id
picture_hash_id
picture_filename
user_id
picture_upload_time

// AFTER:
pictureId
pictureHashId
pictureFilename
userId
pictureUploadTime

See also

  1. Regex - convert from camel case notation to underscore
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join