"^\\w+ ([-_.]?" \\w+) *@\\w+ ([\\.-]?\\w+) * (\\.\\w{2,6}) +$ "
This is my Java program to check the e-mail format is legitimate regular expression, see a blog post on the Internet, and I used the expression similar, reprinted over, for everyone to study together.
------------------------------The following are reproduced articles-----------------------------------
Regular expressions (regular expression, often abbreviated as REGEXP) is a pattern written in special notation that describes one or more text strings. Use regular expressions to match patterns of text so that the script can easily identify and manipulate the text. In fact, regular expressions are worth the time to learn. Regular expressions are useful not only in JavaScript, but also in many other places, such as other programming languages (such as Perl,java,c#,python and PHP), Apache configuration files, and text editors such as BBEdit and TextMate. Even Adobe Dreamweaver and Microsoft Word (to some extent) use regular expressions to achieve more powerful searches and replacements.
The following is a regular expression that validates an e-mail message
var re =/^\w+ ([\.-]?\w+) *@\w+ ([\.-]?\w+) * (\.\w{2,3}) +$/;
Now we're going to start dissecting this regular expression.
Re is a variable that stores the right regular expression, and in JavaScript, declares the variable to use the var keyword.
The reading order of regular expressions is Left-to-right
Regular expressions always start with (/) and end, and all content between slashes is part of a regular expression.
The caret (^) indicates that we want to use this expression to examine a string that begins with a particular string. If you remove the caret, the e-mail address may be considered valid even if there is a heap of junk characters at the beginning of the string.
An expression \w represents any single character, including A~z, A~z, 0~9, or underscores. E-mail must start with these words Fu Zhi.
Plus + means we're looking for one or more occurrences of the previous entry.
The brackets () represent a group, which means that all of the contents of the parentheses are referenced later, so they are now placed in a group.
The bracket [] is used to indicate that any one of these characters can appear. In this example, the square brackets contain the character \.-. We want to allow the user to enter the dot or hyphen, but the point number is special to the regular expression, so you need to precede it with a backslash \, and a backslash before the special character to represent the word escape, and the escaped character to represent its meaning. Because of parentheses, the input string can have a dot or a hyphen in this position, but both cannot exist at the same time.
Question mark. Indicates that the preceding entry can appear once or not. So the first part of the e-mail address can have a dot or a hyphen, or it may not.
In. Later, use \w+ again to indicate that there must be other characters after the dot or hyphen.
The * number that appears after () indicates that the preceding entry can appear 0 or more times. So the contents of the parentheses can appear 0 or more times.
The @ character represents itself, without any other meaning, which is between the e-mail address and the domain name.
The @ character appears again after the \w+, indicating that the character must appear after @. After that, it appears again ([\.-]?\w+) *, which indicates that the dot or hyphen is allowed in the suffix of the e-mail address.
Then, create another group (\.\w{2,3}) in a pair of parentheses, indicating that we want to find a point number followed by some characters. In this example, the number in the curly braces indicates that the preceding entry can appear between 2 and 3 times. After this group is a + number, which means that the previous entry (this group) must appear one or more times. This will match. com or. edu, and also match ox.ac.uk.
Finally, the end of the regular expression is a dollar sign $, which means that the matching string must end here. The slash ends the regular expression.