Skip to content

Instantly share code, notes, and snippets.

@MelMacaluso
Forked from dbowling/gist:2589645
Last active August 22, 2018 17:30
Show Gist options
  • Save MelMacaluso/a57ebc8a5ac1f4c5df45b705ffb22ffa to your computer and use it in GitHub Desktop.
Save MelMacaluso/a57ebc8a5ac1f4c5df45b705ffb22ffa to your computer and use it in GitHub Desktop.
Convert text to a valid CSS class name
string = 'Invalid C$$ class name';
// Actually delete the spaces too...
string.replace(/[!\"#$%&'\(\)\*\+,\.\/:;<=>\?\@\[\\\]\^`\{\|\}|\s~]/g, '').toLowerCase();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment