Domanda

Hi I have the following code that that uses the eregi() function that PHP is saying is depreciated. I am trying to convert it into a replacement function (preg match) but im not too sure how to go about it as I am new to preg match function.

eregi ('^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$', stripslashes(trim($_POST['email'])))

How can I layout the above code in the preg match function?

Thanks

È stato utile?

Soluzione

filter_var(stripslashes(trim($_POST['email'])), FILTER_VALIDATE_EMAIL) 

will do the task you are trying to complete, and it validates email addresses even better ;)

Otherwise use preg_match and replace [:alnum:] with [0-9A-Za-z] in the pattern.

See

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