Reputation: 55
I am trying to check text with regular expression and i need to check if it contains only letters, spaces and also non english characters.
I have this one:
var check = /^[a-zA-Z_0-9][a-zA-Z_0-9\s]*$/g.test(input.value);
It works fine but if input.value contains "ã" or "é" it gives false.
I googled and find that you can use unicode filter like this:
/\p{L}/u
I tryed to combine but with no results.
How can i solve this?
Thank you all.
Upvotes: 0
Views: 1048
Reputation: 274
The following will include extended latin characters:
var check = /^[a-zA-Z_0-9\u00C0-\u017F][a-zA-Z_0-9\u00C0-\u017F\s]*$/g.test(input.value);
See https://en.wikipedia.org/wiki/Latin_script_in_Unicode for more information.
Upvotes: 1