You Know What an Email Address Is, Right?

Agreed! Valid can be not terribly valid.

Nine! Also using internet for decades

Some were so silly that I should’ve guessed valid but tried to use logic.

1 Like

At the risk of reopening the late 1990s debate on what the definition of ā€œisā€ is, I’d note that your question asked whether ā€œit is [poor word order for a question] legal.ā€ ā€œIsā€ is the present tense of the verb to be, so it is illegal.

I’d say there is a more fundamental problem with that quiz question? It isn’t clear if the question involves ā€œstrictlyā€, legality, the Constitution, or something else?

Yet another example of how English is continually changing? The current trend of indicating a question by adding a question mark to a declarative sentence instead of word order is moving English closer to Asian languages?

;-)

1 Like

Typo, I meant to ask ā€œis it legalā€¦ā€. Fixed now.

As I was going to a client today, I passed a street called ā€œLee Way Courtā€; try telling somebody on the phone that address!

2 Likes

OK, for fun and the two other Regex geeks on the forum. . . .

Some years ago I wrote a freeform address recognition app, FormalAddress, (think of copying a webpage and having it find three street addresses, phone numbers, and emails and sending them to your address book). It’s off the market, now, because the cost of maintaining it came to far surpass the revenue. :frowning: :thinking: :slightly_smiling_face:

Here is the simplified version of the e-mail address recognizer. It worked for years for a few thousand users and was tested against a semi-random sample of a couple hundred thousand world wide addresses.

I’ve included the documentation comments for your amusement.

# Python flavor of grep.
# V4 20170302 Yeesh. Let's add all sorts of RFC characters nobody
# uses and watch performance plummet.
# V4 20180112 changed TLD to accept unlimited length
# (Sheesh, I'm so eighties...)

(?<!\.)([-\w.&*~#+%!{}]+)\x20?@\x20?([-a-zA-Z0-9]+\.)+[a-zA-Z]{2,}

# Case Insensitive and Multi line

Note this is not a validation regular expression. If you have unbalanced brackets in there it will still take it. For some reason many, many people don’t make sure the email address on their website is correct so we just grabbed what looks email-y and let the user fix it. :grinning: :grinning: :grinning:

In the five or six years I was working on FormalAddress in intensive sprints I don’t think I ever saw any of the email forms in that very amusing quiz. Well, maybe once—some research lab somewhere.

Dave

FWIW. I generally recommend against trying to validate at all before use; simply send an email to it, and if the recipient responds, it’s valid. This saves a lot of grinding of teeth when a perfectly valid address is rejected because reasons—wrong reasons.

Of course, now you have to be extremely careful that you only provide the address to your email server/platform in a way that’s unambiguous, i.e. so it can’t be interpreted as anything but an email, for instance, a command line argument that undergoes no further interpretation, or an SMTP command that contains no injected parameters. But, if your development platform allows, that provides the greatest flexibility and is in many ways much cleaner than using regexes to achieve the same goal. But, it does require great care to ensure you don’t inadvertently add a security vulnerability.