Analysis on checking the Regular Expression of email

Source: Internet
Author: User

How do we use to check the Regular Expression of email? What are the steps required to check the Regular Expression of email? The operation instance for checking the Regular Expression of email will show you in detail.

Let's continue to discuss how to verify an email address. there are three parts in a complete email address: POP3 User Name (everything on the left of '@'), '@', and server name (that is, the remaining part ). the user name can contain uppercase and lowercase letters, Arabic numerals, periods ('. '), minus sign ('-'), and underline ('_'). the server name also complies with this rule, except for the underlines.

Check the discussion about the regular expression of email:

The start and end of the user name cannot be a period. the same is true for servers. you cannot have at least one character between two consecutive periods. Now let's take a look at how to write a matching pattern for the user name:

^ [_ A-zA-Z0-9-] + $

The end cannot exist yet. We can add the following:

^ [_ A-zA-Z0-9-] + (. [_ a-zA-Z0-9-] +) * $

The above means: "There is at least one canonicalized character (except. Unexpected), followed by 0 or more strings starting with a point ."

Check the implementation of the regular expression of email:

To simplify it, we can use eregi () to replace ereg (). eregi () is case-insensitive and we don't need to specify two ranges: "a-z" and "A-Z"-Just specify one:

^ [_ A-z0-9-] + (. [_ a-z0-9-] +) * $

The server name is the same, but the underline should be removed:

^ [A-z0-9-] + (. [a-z0-9-] +) * $

Done. Now you only need to use @ to connect the two parts:

^ [_ A-z0-9-] + (. [_ a-z0-9-] +) * @ [a-z0-9-] + (. [a-z0-9-] +) * $

This is the complete email authentication matching mode. You only need to call

Eregi ('^ [_ a-z0-9-] + (. [_ a-z0-9-] +) * @ [a-z0-9-] + (. [a-z0-9-] +) * $ ', $ eamil)

Then you can check whether the email is used.

Here we will introduce you to the content related to checking the Regular Expression of email. I hope it will be helpful for you to understand and learn how to check the Regular Expression of email.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.