TheBigRoomXXL@leminal.space to Programmer Humor@programming.devEnglish · 2 days agoEveryone knows what an email address is, right? (Quiz)e-mail.wtfexternal-linkmessage-square152fedilinkarrow-up1879arrow-down18
arrow-up1871arrow-down1external-linkEveryone knows what an email address is, right? (Quiz)e-mail.wtfTheBigRoomXXL@leminal.space to Programmer Humor@programming.devEnglish · 2 days agomessage-square152fedilink
minus-squarenotarobot@lemmy.ziplinkfedilinkarrow-up1·20 hours agoI’m not sure I blame the sites. The spec is so complex that it’s not even possible to know which regex to use
minus-squareulterno@programming.devlinkfedilinkEnglisharrow-up0·33 minutes agoI have a feeling, the ones codapine is stating, didn’t even care to half-read the spec and just went with what they knew from experience. Maybe they didn’t even know there was a spec. Maybe they asked ChatGPT for the regex.
minus-squarebignose@programming.devlinkfedilinkEnglisharrow-up1·edit-26 hours ago The spec is so complex that it’s not even possible to know which regex to use Yes. Almost like a regex is not the correct tool to use, and instead they should use a well-tested library function to validate email addresses.
minus-squareaxEl7fB5@lemmy.cafelinkfedilinkEnglisharrow-up2arrow-down1·18 hours agoconst emailRegExp = /^[\w.!#$%&'*+/=?^`{|}~-]+@[a-z\d-]+(?:\.[a-z\d-]+)*$/i; per the HTML specification. From https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation#validating_forms_without_a_built-in_api
minus-squarenotarobot@lemmy.ziplinkfedilinkarrow-up2·18 hours agoThat’s one very random place to find that. There are a lot of different one and there is no way we all just agree to use that one. Look art his site that shows a more complete and (in theory) official website. While also explaining that there is no regex that is perfect https://emailregex.com/ (Compete regex for the lazy) (?:\[a-z0-9!#$%&'\*+/=?^\_\`{|}\~-]+(?:\\.\[a-z0-9!#$%&'\*+/=?^\_\`{|}\~-]+)\*|"(?:\[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])\*")@(?:(?:\[a-z0-9]\(?:\[a-z0-9-]\*\[a-z0-9])?\\.)+\[a-z0-9]\(?:\[a-z0-9-]\*\[a-z0-9])?|\\\[(?:(?:25\[0-5]|2\[0-4]\[0-9]|\[01]?\[0-9]\[0-9]?)\\.){3}(?:25\[0-5]|2\[0-4]\[0-9]|\[01]?\[0-9]\[0-9]?|\[a-z0-9-]\*\[a-z0-9]:(?:\[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])
minus-squareaxEl7fB5@lemmy.cafelinkfedilinkEnglisharrow-up2·11 hours agoMDN isn’t a very random place?
minus-squarenotarobot@lemmy.ziplinkfedilinkarrow-up1·9 hours agoNo. But it’s on the form validation topic.
I’m not sure I blame the sites. The spec is so complex that it’s not even possible to know which regex to use
I have a feeling, the ones codapine is stating, didn’t even care to half-read the spec and just went with what they knew from experience.
Maybe they didn’t even know there was a spec.
Maybe they asked ChatGPT for the regex.
Yes. Almost like a regex is not the correct tool to use, and instead they should use a well-tested library function to validate email addresses.
const emailRegExp = /^[\w.!#$%&'*+/=?^`{|}~-]+@[a-z\d-]+(?:\.[a-z\d-]+)*$/i;
per the HTML specification. From https://developer.mozilla.org/en-US/docs/Learn_web_development/Extensions/Forms/Form_validation#validating_forms_without_a_built-in_api
That’s one very random place to find that. There are a lot of different one and there is no way we all just agree to use that one.
Look art his site that shows a more complete and (in theory) official website. While also explaining that there is no regex that is perfect
https://emailregex.com/
(Compete regex for the lazy)
(?:\[a-z0-9!#$%&'\*+/=?^\_\`{|}\~-]+(?:\\.\[a-z0-9!#$%&'\*+/=?^\_\`{|}\~-]+)\*|"(?:\[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])\*")@(?:(?:\[a-z0-9]\(?:\[a-z0-9-]\*\[a-z0-9])?\\.)+\[a-z0-9]\(?:\[a-z0-9-]\*\[a-z0-9])?|\\\[(?:(?:25\[0-5]|2\[0-4]\[0-9]|\[01]?\[0-9]\[0-9]?)\\.){3}(?:25\[0-5]|2\[0-4]\[0-9]|\[01]?\[0-9]\[0-9]?|\[a-z0-9-]\*\[a-z0-9]:(?:\[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])
MDN isn’t a very random place?
No. But it’s on the form validation topic.