Domanda

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

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top