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)) { Quote Link to comment 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. Quote Link to comment 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', '\-', '\.' ---------------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted June 12, 2008 Author Share Posted June 12, 2008 perfect thx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.