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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.