Created
          October 19, 2022 08:23 
        
      - 
      
- 
        Save himalay/5a3f5b315ca87537ca223c7188c27966 to your computer and use it in GitHub Desktop. 
    Create a valid CSS class name from a string
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function createCssClassName(str: string) { | |
| return str | |
| .toLowerCase() | |
| .replace(/^(-?[0-9]|--)|[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "") | |
| .trim() | |
| .replace(/\s+/g, "-"); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment