Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Javascript: Humanize words
['hey_you', 'hey-you', 'hey-You', 'heyYou'].map(txt => {
let result = txt.replace(/[a-z][A-Z]/, (val, i) => {
return `${val[0]} ${val[1]}`;
}).replace(/[-|_]/, ' ').toLowerCase();
return result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment