Regex to validate an email input with the following rules...
Whole address:
Up to 254 characters.
Case insensitive.
Username and domain separated by @ symbol.
Only one @ symbol allowed.
No spaces allowed.
Username:
1 to 64 characters.
Any letter, digit and symbol from these #!%$'&+*-/=?^_.{|}~ are allowed.
It cannot start or end with a dot.
It cannot have two (or more) consecutive dots.
Domain:
Only letters, digits and hyphens (and dots of course) allowed.
It cannot start or end with a dot.
Unlimited number of labels separated by one dot allowed.
No label can start nor end with hyphens.
It cannot have two (or more) consecutive dots.
2 to 63 characters per label.
It cannot have an all-numerical TLD.