News for hackers. Stuff that matters.
Re:Ruby's Email Address Regexp by lilyball on Tuesday January 04, 2022 @10:00PM (#29804479)
This depends on your use-case. If you're writing a mail agent, then you do probably want to parse email addresses in their entirety. If you're writing a website that accepts email addresses and wants to make sure the user doesn't just type "foo", then yeah, check for `.+@.+` and call it a day.
Re:Ruby's Email Address Regexp by runarberg on Tuesday January 04, 2022 @10:03PM (#29804502)
If you are writing a webpage that accepts email addresses, then please just use <input type="email"> and check for:

    document.querySelector("[type='email']").validity.valid
This will not only give you email validation for free, but also gives users with software keyboards (e.g. on phones) a contextual keyboard.
Re:Ruby's Email Address Regexp by tokumei on Tuesday January 04, 2022 @10:51PM (#29804898)
That’s just for the client though. Best to check on the server as an authoritative source of truth.