Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  89] [ 2]  / answers: 1 / hits: 65016  / 14 Years ago, sat, june 19, 2010, 12:00:00

From this questions : javascript regex : only english letters allowed



How can I make that expression test for people's name? Currently it doesn't allow spaces between names at all. I need to be able to match something like John Doe



Cheers


More From » regex

 Answers
71



let result = /^[a-zA-Z ]+$/.test( 'John Doe');
console.log(result);





Throw any symbols you need in the character class. This is why I said be specific about exactly what you want to validate. This regex will not account for accented characters, if you care about that you'd most likely better go with unicode matching.


[#96453] Wednesday, June 16, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
maureen

Total Points: 151
Total Questions: 110
Total Answers: 110

Location: Mali
Member since Fri, Dec 3, 2021
3 Years ago
;