jamesjmann Posted March 21, 2011 Share Posted March 21, 2011 preg_match("/^[a-zA-Z] [a-zA-Z0-9]{8, 13} [\_]{1, 1} \@ [a-zA-Z0-9]{1, 15} \. [a-zA-Z]{2, 4}$/", $string); Basically what I want it to check to see is that the email starts with one lowercase or uppercase letter. Then make sure the email contains only a-zA-Z0-9 characters than can span up to 13 chars long. And that a hyphen may be used if necessary, but is not required. Then of course make sure there is an "@" sign. The rest is to make sure that the domain name is only consisted of a-zA-Z0-9 characters that may be up to 15 characters long. Also, require a period right after, and then the TLD, which I would imagine the largest is only 4 characters long. Is that what the above does? If not, can someone guide me in the right direction and help correct any errors, if applicable? Quote Link to comment https://forums.phpfreaks.com/topic/231322-is-this-a-suitable-preg_match-for-checking-an-email/ Share on other sites More sharing options...
jcbones Posted March 21, 2011 Share Posted March 21, 2011 Take your pick Quote Link to comment https://forums.phpfreaks.com/topic/231322-is-this-a-suitable-preg_match-for-checking-an-email/#findComment-1190547 Share on other sites More sharing options...
jamesjmann Posted March 21, 2011 Author Share Posted March 21, 2011 Take your pick Thanks, but I want to actually LEARN it. That way I don't have to go on some website or steal from someone else whenever I need to script something. I like doing everything on my own, but sometimes I just need a little "push" or "hint". So give me a "push" or "hint" lol Quote Link to comment https://forums.phpfreaks.com/topic/231322-is-this-a-suitable-preg_match-for-checking-an-email/#findComment-1190550 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.