Jump to content

eregi to preg_match


freelance84

Recommended Posts

if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
//email was valid
}

 

Trying to replace the eregi function with preg_match but i dont think its working. This is what i got:

if(preg_match("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
//this email is valid
}

 

What ever the content of $email in the preg_match version, it simply returns true... is the pattern wrong for preg_match?

 

(patterns are no strong point of mine at the moment)

Link to comment
https://forums.phpfreaks.com/topic/237512-eregi-to-preg_match/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.