Skip to content

Instantly share code, notes, and snippets.

@AmrAbdulrahman
Created May 16, 2019 12:32
Show Gist options
  • Save AmrAbdulrahman/a4b9fce05abfc147dff963e5f6c8674e to your computer and use it in GitHub Desktop.
Save AmrAbdulrahman/a4b9fce05abfc147dff963e5f6c8674e to your computer and use it in GitHub Desktop.
Convert camelCase to space separated words
'camelCaseStyle'
.split(/([a-z][A-Z])/g)
.reduce((words, group, index) => (index % 2 ? `${words}${group[0]} ${group[1]}` : `${words}${group}`), '')
@abumostafa
Copy link

abumostafa commented May 16, 2019

"camelCaseStyle".replace(/[A-Z]/g, l => ` ${l.toLocaleLowerCase()}`) // camel case style
"camelCaseStyle".replace(/[A-Z]/g, l => ` ${l}`) // camel Case Style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment