0

I used to use my function with ereg (check that there's one @ symbol),

ereg("^[^@]{1,64}@[^@]{1,255}$", $email)

but now it is deprecated. Why I am getting an error preg_match(): Unknown modifier '@' when I fixed it to preg_match("^[^@]{1,64}@[^@]{1,255}$", $email)?

Andrew
  • 7,619
  • 13
  • 63
  • 117

2 Answers2

1

You need to add delimiters around your expression.

preg_match("/^[^@]{1,64}@[^@]{1,255}$/", $email)

I strongly suggest to start reading about PCRE pattern syntax.

Tchoupi
  • 14,560
  • 5
  • 37
  • 71
0

if you want to validate an email address:

preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $email);

this may help you.

koogua
  • 254
  • 5
  • 18