Help with validating emailadress (preg_match)
Hi,
I am trying to validate an emailadress, so that you enter a valid email. I am using this script:
PHP Code:
$email = 'user@domain.com';
if (preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$^", $email)) {
echo 'Email is correct!';
}
The expression i did not come up with myself, i found it, I dont fully understand it tho. Is there someone (PLEASE!) that can break it up and try to explain what the different blocks mean?
I realize that the [_a-z0-9-] is the valid chars, but how about the other things? Like the ^ at the beginning, and what difference does the + and the * make between them blocks?
Anyway, i would truly love it if someone would try to explain this to me. Thanks!
Hugs / Merilille