Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
18
rated 0 times [  22] [ 4]  / answers: 1 / hits: 49662  / 12 Years ago, sat, july 28, 2012, 12:00:00

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,}/.


More From » node.js

 Answers
15

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.


[#84001] Friday, July 27, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pranavrorys

Total Points: 466
Total Questions: 87
Total Answers: 115

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
pranavrorys questions
Fri, May 27, 22, 00:00, 2 Years ago
Thu, Oct 28, 21, 00:00, 3 Years ago
Sat, May 30, 20, 00:00, 4 Years ago
Fri, Dec 20, 19, 00:00, 5 Years ago
;