ballhogjoni Posted June 11, 2008 Share Posted June 11, 2008 Hi everyone, I came across this code to check whether an email address is valid or not. Can someone explain the syntax. I looked on php.net, but it doesn't explain what all the characters mean. Thx. if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z\-\.]", $email)) { Link to comment https://forums.phpfreaks.com/topic/109734-solved-eregi-syntax-explanation/ Share on other sites More sharing options...
ballhogjoni Posted June 11, 2008 Author Share Posted June 11, 2008 I figured some of it out on my own. With eregi you don't need to escape anything because the [] do that. I don't know what the ^ does though. Link to comment https://forums.phpfreaks.com/topic/109734-solved-eregi-syntax-explanation/#findComment-563123 Share on other sites More sharing options...
effigy Posted June 11, 2008 Share Posted June 11, 2008 You need $ at the end. Here's the rest: NODE EXPLANATION ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- [a-zA-Z0-9_]+ any character of: 'a' to 'z', 'A' to 'Z', '0' to '9', '_' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- @ '@' ---------------------------------------------------------------------- [a-zA-Z0-9\-]+ any character of: 'a' to 'z', 'A' to 'Z', '0' to '9', '\-' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \. '.' ---------------------------------------------------------------------- [a-zA-Z\-\.] any character of: 'a' to 'z', 'A' to 'Z', '\-', '\.' ---------------------------------------------------------------------- Link to comment https://forums.phpfreaks.com/topic/109734-solved-eregi-syntax-explanation/#findComment-563134 Share on other sites More sharing options...
ballhogjoni Posted June 12, 2008 Author Share Posted June 12, 2008 perfect thx Link to comment https://forums.phpfreaks.com/topic/109734-solved-eregi-syntax-explanation/#findComment-563571 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.