Skip to content

Instantly share code, notes, and snippets.

@sgabber
Created October 4, 2019 09:12
Show Gist options
  • Save sgabber/38233b47cc9bfd6bf49ac14626a61268 to your computer and use it in GitHub Desktop.
Save sgabber/38233b47cc9bfd6bf49ac14626a61268 to your computer and use it in GitHub Desktop.
From camelcase to db column name
find
/([a-z_]*)([A-Z])(.*?$)/
replace with
/\1_\l\2\3/
repeatedly
from db column name to camelcase (table name should be only lowercase and underscores)
find
/([a-z]*)_([a-z])/
replace with
/\1\u\2/
find all double quotes out of square brackets (to convert them to single quotes)
find
(?<!\])"(?!\[)
replace
'
sample case: "["testing","of","regex"]" -> "['testing','of','regex']"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment