Discuss Email validation ALIEN code in the PHP Development forum on Dev Shed. Email validation ALIEN code PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
Posts: 1,572
Time spent in forums: 1 Week 6 Days 16 h 19 m 9 sec
Reputation Power: 438
Email validation ALIEN code
I would like a deeper understanding of email-validation. Specifically with the ALIEN-like string we run against user, and host in email addresses. "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}-]+" for example. This string is used against the 'user' section of our email addresses.
All of the information I have found on email validation just takes pre-existing examples of this for granted, and offer to explanation for what this actually means. Can anybody here decypher this insane garble so I can have a better understanding as to what is actually taking place? I am not just a 'copy, paste, good - now the job is done." I want a deeper understanding Call me old-fashioned!
Posts: 14,817
Time spent in forums: 1 Month 1 Week 4 Days 7 h 14 m 56 sec
Reputation Power: 1098
By user section I assume you mean foo in foo@domain.com? No matter really, I guess. I can tell you the literal equivalent for this regular expression, but w/o seeing it in context it's hard to say exactly how it's used.
" begin string
/ begin pattern (there should be a matching / at the end of the pattern)
^ match starting at the beginning of the searched string
[ begin a character class; a set of characters
-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}- these characters literally, \\ is an escaped \, \/ is an escaped / (which is required so the interpreter doesn't think it's the end of the pattern), 0-9 is all numbers, A-Z is all upper case letters
] ends the character class
+ means to match one of the characters in the preceeding character class at least once, or "one or more times"
" ends string
__________________
# Jeremy
Explain your problem instead of asking how to do what you decided was the solution.