KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
(Edit: What is Code Golf: Code Golf are challenges to solve a specific problem with the shortest amount of code by character count in whichever language you prefer. More info here on Meta StackOverflow. ) Code Golfers, here's a challenge on string operations. Email Address Validation , but without regular expressions (or similar parsing library) of course. It's not so much about the email addresses but how short you can write the different string operations and constraints given below. The rules are the following (yes, I know, this is not RFC compliant, but these are going to be the 5 rules for this challenge): At least 1 character out of this group before the @: A-Z, a-z, 0-9, . (period), _ (underscore) @ has to exist, exactly one time john@smith.com ^ Period (.) has to exist exactly one time after the @ john@smith.com ^ At least 1 only [A-Z, a-z] character between @ and the following . (period) john@s.com ^ At least 2 only [A-Z, a-z] characters after the final . period john@smith.ab ^^ Please post the method/function only, which would take a string (proposed email address) and then return a Boolean result (true/false) depending on the email address being valid (true) or invalid (false). Samples: b@w.org (valid/true) @w.org (invalid/false) b@c@d.org (invalid/false) test@org (invalid/false) test@%.org (invalid/false) s%p@m.org (invalid/false) j_r@x.c.il (invalid/false) j_r@x.mil (valid/true) r..t@x.tw (valid/true) foo@a%.com (inv
Tags (comma-separated)
Save Edits
Cancel