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.
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?
;-)
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!
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.
![]()
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.
![]()
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.