Sep 1 2007

Php Regular Expressions and Validations

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

TAGS:

LEAVE A COMMENT

Subscribe Form

Subscribe to Blog

Sponsors

    Advt on sajithmr.com
    Advt on sajithmr.com
    Itslife Online
    Advt on sajithmr.com

Recent Comments

  • Binny V A: Thanks for the post - love the picture ;-)
  • TheAnand: A lot of people are seeing errors with google video chat….is there any other software which has to be...
  • Alex: Wow, interresting analysis you have done! I’m trying to run GoogleVoiceAndVideoSetup on linux, using...
  • Mella Fitriansyah: Nice plugin, I will try to add this plugin in my blog…
  • Mella Fitriansyah: Nice Info, Sir i will reading your another post success for you

Recent Readers

JOIN MY COMMUNITY!

Recent Posts