Page 1 of 1
Question
Posted: Fri Oct 14, 2005 7:29 pm
by icesolid
How come this will not produce a result:
Code: Select all
<?php
if(eregi(".", $_POST["email"])) {
echo "valid e-mail\n";
} else {
echo "not a valid e-mail\n";
}
?>
It will allow name@sitecom without producing "not a valid e-mail".
Am I missing something?
Posted: Fri Oct 14, 2005 7:31 pm
by feyd
a dot, is a metacharacter in regex.. it matches any character.
So.....
Posted: Fri Oct 14, 2005 7:36 pm
by icesolid
How can I scan the string for a . (period)?
Posted: Fri Oct 14, 2005 7:37 pm
by feyd
escape the character, \.
No...
Posted: Fri Oct 14, 2005 7:45 pm
by icesolid
I want to user to enter the period for their e-mail. I just want to be sure they are entering it. How would escaping it help me?
Posted: Fri Oct 14, 2005 7:47 pm
by feyd
escaping tells regex to match the character, not the metacharacter.
Thank You
Posted: Fri Oct 14, 2005 8:10 pm
by icesolid
Yeah I got what you were saying (im slow sometimes).
New code:
Code: Select all
<?php
if(eregi("\.", $_POST["email"])) {
echo "valid e-mail\n";
} else {
echo "not a valid e-mail\n";
}
?>