Skip to content

Instantly share code, notes, and snippets.

@richard457
Created March 14, 2019 09:25
Show Gist options
  • Save richard457/0e8d4a11c51955539337a0469d16b6a1 to your computer and use it in GitHub Desktop.
Save richard457/0e8d4a11c51955539337a0469d16b6a1 to your computer and use it in GitHub Desktop.
Cleaning a string in JavaScript.
let dirtyString= "[Hello world]";
dirtyString.replace(/([^a-z0-9]+)/gi, '');
console.log(dirtyString); // Hello world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment