I want to do some basic String testing in Node.js. Assume I have a form where users enter their name and I wanna check if it's just rubbish or a real name.
Happily (or sadly for my check) I get users from all around the world which means that their names contain non-english characters, like ä ö ü ß é
. I was used to use /[A-Za-z -]{2,}/
but this doesn't match names like "Jan Buschtöns"
.
Do I have to manually add every possible non-english but latin character to my RegEx to work? I don't want a 100+ characters long RegEx like /[A-Za-z -äöüÄÖÜßéÉèÈêÊ...]{2,}/
.
Check http://www.regular-expressions.info/unicode.html and http://xregexp.com/plugins/
You would need to use \p{L}
to match any letter character if you want to include unicode.
Speaking unicode, alternative of \w
is [\p{L}\p{N}_]
then.