On Tue, Dec 29, 2020 at 10:08 AM Avi Gross via Python-list <python-list@python.org> wrote: > > This may be a nit, but can we agree all valid email addresses as used today > have more than an @ symbol? > > I see it as requiring at least one character before the @ that come from a > list of allowed characters (perhaps not ASCII) but does not include the > symbol @ again. It is normally followed by some minimal number of characters > and maybe a period and one of the currently valid domains like .com or .it > but the latter gets tricky as it can look like u...@abd.def.att.com or other > long variations where only the final component must be testable in the > program.
There can be an @ in the first part of the address, and the domain may well not have a dot. > The lack of an at-sign suggests it is not an email address. The lack of > anything before or after also seems to disqualify it. You may be able to add > more conditions but as noted, having more than one at-sign may also > disqualify it. Lack of an at sign means it's a local address that can't be routed over the internet, and in many contexts, it's reasonable to exclude those. But two isn't illegal. > I am sure someone has some complex regular expressions that they think > matches only potentially valid strings but, of course, as noted by Chris, to > really validate that an address works might require sending something and > validating a human replied and that can be quite task. > Yes, many such regexes exist, and they are *all wrong*. Without exception. I don't think it's actually possible for a regex to perfectly match all (syntactically) valid email addresses and nothing else. ChrisA -- https://mail.python.org/mailman/listinfo/python-list