I am using ^([a-zA-Z0-9_\-\.\']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$
to validate emails. But this regex is not validating consecutive periods. What can I change to accept consecutive periods?
test..test@test.com
. Just as a side note, be aware that you are not supporting all email addresses with that regex. If you want to truly validate emails you need to reference RFC 822 and RFC 5322. – Nathan Nov 13 '14 at 19:33-.-.-.-.@0.1.2.aa
, not sure it's a valid address. But it doesn't matchme@localhost
that is valid. – Toto Nov 13 '14 at 19:43+*%=&$
and a number of other valid characters.+
in particular is aggravating because addresses with a plus in them are a common feature for extending mailbox names -- for example, on servers which support this extension, if you ownyou@example.com
, you could create a dedicated addressyou+stackoverflow@example.com
without setting up a separate physical mailbox. – tripleee Nov 13 '14 at 19:49