-3

I don't know anything about regex.

How do I create an email validation that allows such entries?

Allow

a1b2c3@a1b2c3
a@a
1@1
a1@a@a2e
!s@s$ds

Dont Allow

@
@@@
!@#

Basically allow characters that has @ in the middle

  • 4
    [Stop trying to validate email addresses with regular expressions](https://stackoverflow.com/questions/1076573/); it cannot work. You can check if the `@` is not at the beginning nor end of the address, but to validate an email address [you have to send an email](https://davidcel.is/posts/stop-validating-email-addresses-with-regex/). – Dour High Arch Aug 10 '20 at 16:26
  • The best way to validate an email address is to send an email and check the return value. Please, have a look at these sites: [TLD list](https://www.iana.org/domains/root/db); [valid/invalid addresses](https://en.wikipedia.org/wiki/Email_address#Examples); [regex for RFC822 email address](http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html) – Toto Aug 10 '20 at 17:32

1 Answers1

0

If you aren't fluent in regex you can split the string at "@" and expect two elements.

If you want to use regex, the first result on google was: https://emailregex.com

Fumeaux
  • 36
  • 1
  • 9