decamelize
Convert a camelized string into a lowercased one with a custom separator
Example: unicornRainbow
→ unicorn_rainbow
If you use this on untrusted user input, don't forget to limit the length to something reasonable.
Install
npm install decamelize
Usage
import decamelize from 'decamelize';
decamelize('unicornRainbow');
decamelize('unicornRainbow', {separator: '-'});
decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
decamelize('testGUILabel', {preserveConsecutiveUppercase: false});
API
decamelize(input, options?)
input
Type: string
options
Type: object
separator
Type: string
Default: '_'
Character or string inserted to separate words in string
.
import decamelize from 'decamelize';
decamelize('unicornRainbow');
decamelize('unicornRainbow', {separator: '-'});
preserveConsecutiveUppercase
Type: boolean
Default: false
Preserve sequences of uppercase characters.
import decamelize from 'decamelize';
decamelize('testGUILabel');
decamelize('testGUILabel', {preserveConsecutiveUppercase: true});
Related
See camelcase
for the inverse.