Php Regular Expressions and Validations
![]()
Php regular expression to validate an email address
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
$email = 'sajithmr2005@yahoo.com';
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",
$email))
{
echo 'valid email' ;
}
?>
//Regular Expression for Validate a number
$mobile = '9846831106';
if ( ereg('^[[:digit:]]+$', $mobile) )
{
echo 'valid number';
}
?> |
Regular Expression for Removing non-alphabetic characters from a string or a Filename.
$newFilename = preg_replace(“/[^a-zA-Z0-9s.]/”, “”, $newFilename);

