I'm was using PHP eregi function, but I get the notice that it is deprecated. Here's my code:
!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))
Therefore I am trying to replace the function with the preg_match, but seems that I am unable to get the correct pattern for the preg_match, as I get error with the following code:
!preg_match("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))
Here's the error I get from above code:
Warning: preg_match(): No ending delimiter '^' found in
Thanks for any help.
You need to use a delimiter at the beginning and end of your regex, commonly /
:
!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/", trim($_POST['email']))
Manual entry: PCRE introduction / delimiters