Skip to content

Instantly share code, notes, and snippets.

@germanattanasio
Last active November 4, 2020 13:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save germanattanasio/84cd25395688b7935182 to your computer and use it in GitHub Desktop.
Save germanattanasio/84cd25395688b7935182 to your computer and use it in GitHub Desktop.
Basic Latin-1 Letter Regular Expression (JavaScript)
var regexp = /^[A-z\u00C0-\u00ff\s'\.,-\/#!$%\^&\*;:{}=\-_`~()]+$/,
ascii = ' hello !@#$%^&*())_+=',
latin = 'Panamá, ratón, cortés, árbol, azúcar, ángel',
chinese = ' 你 好 ';
console.log(regexp.test(ascii)); // true
console.log(regexp.test(latin)); // true
console.log(regexp.test(chinese)); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment