There are a frightening number of systems that don't allow "-", which isn't even an edge case. A lot of people - mostly women - hyphenate their last names on marriage, rather than throw their old name away. My wife did. She legally changed her name when she came of age, and when we met and married years later she said, "I paid for money for my name; I'm not letting it go." (Note: I wasn't pressuring her to take my name.) So she hyphenated it, and has come to regret the decision. She says she should have switched, or not, but the hyphen causes problems everywhere. It's not a legal character in a lot of systems, including some government systems.
There are also fringe externalities from this too. I have my mom's last name for my middle name and my dad's for my last name. But back in the 90s, my state would erroneously handle that scenario as having no middle name and both names hyphenated for a last name. I didn't find this out until I turned 18 and tried to get a retail job and they wouldn't hire me until it got fixed.
First I had to go to the Dept of Health and get a new birth certificate, then I had to do the same at the social security administration for a new social security card. Hours and hours over multiple days just so I could earn minimum wage folding and selling used clothing. Ironically, the name mixup never was a problem when I did taxes previously.
There are many regexes that validate email, and they usually aren't compliant with the RFC, there are some details in the very old answer on SO. So, better not validate and just send a confirmation, than restrict and lock people out, imo
The article you just mentioned in the comments includes both a completely reasonable and viable regex and binary and library alternatives that are in most languages.
There is some danger that common usage and widespread sloppy coding will establish a de facto standard for e-mail addresses that is more restrictive than the recorded formal standard.
Well, and remember: If in doubt, send them an e-mail. You probably want to do that anyways to ensure they have access to that mailbox.
You can try to use a regex as a basic sanity check, so they've not accidentally typed a completely different info into there, but the e-mail standard allows so many wild mail addresses, that your basic sanity check might as well be whether they've typed an @ into there.
Yeah, I'm just saying that the benefit of using such a regex isn't massive (unless you're building a service which can't send a mail).
a@b is a syntactically correct e-mail address. Most combinations of letters, an @-symbol and more letters will be syntactically correct, which is what most typos will look like. The regex will only catch fringe cases, such as a user accidentally hitting the spacebar.
And then, personally, I don't feel like it's worth pulling in one of those massive regexes (+ possibly a regex library) for most use-cases.
And you'd think a simple solution is just leave out the hyphen when you put you name in, but that can also lead to problems when the system is looking for a 100% perfect match.
And good luck of they need to scan the barcode on your ID.
Then the first part is interpreted (in the US, anyway) as a middle name, not as part of the last name. I did run into a recently married woman who did that: dropped her middle name, moved her last to the middle, and used her spouse's last name.
More commonly, places that don't take hyphens tend to just run the two names together: Axel-Smith becomes AxelSmith.
As someone who's mexican I encounter that more than one would think since I have 2 last names and it gets weird sometimes since I also have a middle name.
Something that could happen in Mexico for a name is Juan Maria as a first, Guillermo David as a middle and Gonzales De Mercado as a last name. Technically 7 words and totally a thing but not common at all, anymore at least.
My mom didn't hyphenate, but she does include her maiden name when writing her full name, after her middle name. It never even occurred to me that that's uncommon.
So she writes 4 names? Does she put her maiden and married names both in the "surname" field? Or middle and maiden together in the "middle name" field?
I have come across a shockingly large amount of people who not only have a hyphenated last name but also have a hypenated first name! Dealing with every new computer system is like a new adventure