正则表达式无法正常工作 - php

时间:2013-04-09 07:22:30

标签: php regex

elseif(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $user_email)) 

即使我尝试了preg_match,我也得到了

警告:

preg_match() [function.preg-match]: No ending delimiter '^' found in C:\wamp\www\Saravanan\jQuery\jQuery - Samples\sign_and_login_using_jquery_ajax_and_php\sign_and_login_using_jquery_ajax_and_php\vpb_save_details.php on line 29
Call Stack

2 个答案:

答案 0 :(得分:2)

使用这个:

if(!filter_var($user_email,FILTER_VALIDATE_EMAIL))

答案 1 :(得分:1)

如果var来自POST:

if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL))