Regex for validating emails
Often times you’re not validating an email address to see if it is real but instead if it is a human or not.
If this is for a user signing up on your website and if you’re going to email them a validation code then you might not need to be too strict. The @ sign is a super simple way to do some easy validation. But you could also throw in some length validation as well which is discussed below. This regex ensures the user typed at least one character before the @ and one after. @won’t match it but it will match most email addresses.But to cover most of the valid email addresses, I am assuming an email address to consist of characters, digits and special characters ,-,. Also, every email address must contain only one @ symbol. So a subdomain can contain characters, digits and special characters – and _. So middle-level TLDs must start with a period (.) and it can contain characters, digits and special characters – and _. The last TLD should be of minimum length 2 and can contain words only. Think about it this way: I register for your website under the email address . That’s probably going to bounce off of the illustrious mail daemon, but the formatting is fine; it’s a valid email address.To fix this problem, you implement an activation system where, after registering, I am sent an email with a link I must click.