Jump to content

Is this a suitable preg_match for checking an email?


jamesjmann

Recommended Posts

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?

 

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

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.