When the regex is not RFC complaint is the worst case, for example, I want to use . or + on my mail address and the website don't allow me.
Stop Validating Email Addresses With Your Complex Regex
11–20 of 211 posts
Re: Stop Validating Email Addresses With Your Complex Regex
#12Incase I've typed it wrong, that should basically work for anything that contains at least one @ and one dot, in that order, as well as at least one character at beginning, middle and end. It's served me well thusfar.
Edit for clarification: The reason I prefer this over just checking for an @ is that if you're just checking for @ a common mistake like "me@hotmail,com" will be considered valid.
Re: Stop Validating Email Addresses With Your Complex Regex
#13Want to know why it's not more common than the regex "method"? His method has its own host of problems - what if your mail server is down for six hours - will people come back to your site six hours later when they get the email? What flags will get set on your sender account when Gmail gets 100,000 bogus email sends? Do you force your users to "Look in your inbox and click the activation link" for every email address change also? There are others but I've made my point. There's a finite amount of "stuff like this" that users will put up with - you can either put the onus to "get it right" on the user (regex validation for emails), or you can put that onus on your system.
An argument for another is always, "If a user can't get their email address entered correctly, I don't want them as a customer". And you can take that multiple ways - technical difficult entering emails, "challenging" email addresses, etc.
Re: Stop Validating Email Addresses With Your Complex Regex
#14I would rather lose a few users through a faulty regexp than lose double digit percentage through an email activation step.
Re: Stop Validating Email Addresses With Your Complex Regex
#15It has regularly come up on HN, and pretty much any programming related forum I've used since the mid-90's.
As an industry at the heart of the information society you have to wonder what the hell we are doing wrong if we cannot stop this constant regression into well known bad practices.
Re: Stop Validating Email Addresses With Your Complex Regex
#16My goto for email validation is /^.+?@.+?\..+?$/ Incase I've typed it wrong, that should basically work for anything that contains at least one @ and one dot, in that order, as well as at least one character at beginning, middle and end. It's served me well thusfar. Edit for clarification: The reason I prefer this over just checking for an @ is that if you're just checking for @ a common mistake like "me@hotmail,com"…
Somewhat artificial, yes.
Re: Stop Validating Email Addresses With Your Complex Regex
#17The driving force is that you want to correct an invalid email ASAP, preferably in the client with live feedback coloring, etc.. Most email services I know don't give you any immediate feedback, and some only give you a basic check that can bounce later. So claiming you just have to check for an @ sign and try sending means there is going to be a huge delay before you know about the error. Saying the user will just c…
Re: Stop Validating Email Addresses With Your Complex Regex
#18Of course there's plenty of ways around that, but this seems to be the most common pattern.
Re: Stop Validating Email Addresses With Your Complex Regex
#19My goto for email validation is /^.+?@.+?\..+?$/ Incase I've typed it wrong, that should basically work for anything that contains at least one @ and one dot, in that order, as well as at least one character at beginning, middle and end. It's served me well thusfar. Edit for clarification: The reason I prefer this over just checking for an @ is that if you're just checking for @ a common mistake like "me@hotmail,com"…
Why not just check for x@x?
Re: Stop Validating Email Addresses With Your Complex Regex
#20(Looking up and implementing a regex) * 1 + (running the regex) * (every email) + (sending email) * (every valid email) Also, this post only considers the signup/activation use case. If you're getting an email for ecommerce to send an order confirmation, you want to know if the email might be invalid before the user completes the order and you try to send it.