Skip to content

Instantly share code, notes, and snippets.

@ErickWendel
Last active March 30, 2021 13:47
Show Gist options
  • Save ErickWendel/6c32544e0686a3374d707a76a2369239 to your computer and use it in GitHub Desktop.
Save ErickWendel/6c32544e0686a3374d707a76a2369239 to your computer and use it in GitHub Desktop.
Example of keeping only words and words which have accents on a JS String
'N,.ã_o)d-á'.replace(/([^A-zÀ-ÿ]|_)/g, '')
// "Nãodá"
// ( => starts a group
// [^A-zÀ-ÿ]=> find only not words including with accents
// |_ => or find _ literally
// ) => ends a group
// g => global - keep searching 'till the end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment