regular.jpg

Php regular expression to validate an email address


$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);


Add to Del.cio.us RSS Feed Add to Technorati Favorites Stumble It!

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!