Skip to content

Instantly share code, notes, and snippets.

@jsdev
Last active December 16, 2016 21:07
Show Gist options
  • Save jsdev/8305476 to your computer and use it in GitHub Desktop.
Save jsdev/8305476 to your computer and use it in GitHub Desktop.
spacedOut method: takes a TitleCased or camelCased string and returns with appropriate spaces
const spacedOut = str => str.replace(/^[a-z]|[A-Z]/g, (v, i) => i === 0 ? v : " " + v);
@jsdev
Copy link
Author

jsdev commented Dec 16, 2016

would take title cased or camel cased strings and turn them into spaced out, so adds a space before Uppercase letters that directly follow a lowercase letter

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