4 ms·
This is what is gives to select names: /^[A-Z][a-z]+(?: [A-Z][a-z]+)*$/ I'm pretty sure quite a lot of people's names wouldn't be accepted by that. It helps if
by thomasahle 4y ago
This is what is gives to select names: /^[A-Z][a-z]+(?: [A-Z][a-z]+)*$/
I'm pretty sure quite a lot of people's names wouldn't be accepted by that.
It helps if you add "even weird and foreign names", but who knows if that's actually enough to capture everything.
- travisjungroth 4y agoIt might be good to say what you want in natural language or have it come up with that from your goal. A regex that worked for all names would be extremely weak. I can’t imagine it being much more than testing valid characters.
- zamnos 4y agoIt's not. I'll be the first one to link to the list of falsehoods programmers believe about names: https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-... It should be required reading before being allowed to write code that'll operate on user profiles, but there's no such thing as a programming license, so this link will have to do.
- rjh29 4y agoThere is basically no regex to validate names except for maybe "is not an empty string".