Match the regular expression of a valid Email

Source: Internet
Author: User
In fact, a regular expression (regularexpression) is a regular expression that consists of common characters (such as characters A to Z) and special characters (called metacharacters) text format. This mode describes one or more strings to be matched when searching the text subject. A regular expression is used as a template to match a character pattern with the searched string. With a regular expression, you can: 1. Test a pattern of a string. For example, you can test an input string to see if there is a phone number or a credit card number. This is called Data Validity verification. 2. Replace text. You can use a regular expression in a document to identify a specific text, and then delete it all or replace it with another text. 3. extract a substring from the string based on the pattern matching. It can be used to search for specific text in text or input fields. For example, if you need to search the entire web site to delete outdated materials and replace some HTML formatting tags, you can use a regular expression to test each file, check whether there are materials or HTML formatting tags in the file. With this method, you can narrow down the affected files to the files that contain the materials to be deleted or changed. Then, you can use a regular expression to delete outdated materials. Finally, you can use a regular expression to find and replace the tags that need to be replaced. Another example that describes the usefulness of regular expressions is a language with unknown string processing capabilities. VBScript is a subset of Visual Basic and has rich string processing functions. Visual Basic Scripting Edition similar to C does not have this capability. Regular Expressions significantly improve the string processing capability of Visual Basic Scripting Edition. However, it may be more efficient to use regular expressions in VBScript. It allows multiple string operations in a single expression. It is precisely because of the powerful functions of the "Regular Expression" that Microsoft has gradually transplanted the regular expression object to the Windows system. Special characters and sequences are used when writing regular expressions. The following table describes the characters and sequences that can be used and provides examples. Character Description: \: Mark the next character as a special character or literal value. For example, "N" matches the character "N. "\ N" matches the linefeed. The sequence "\" matches with "\", and "\ (" matches. ^: Match the start position of the input. $: Matches the end of the input. *: Match the first character Zero or several times. For example, "zo *" can match "Z" and "Zoo ". +: Match the previous character once or multiple times. For example, "zo +" can match "Zoo" but does not match "Z ".?: Match the first character Zero or once. For example, "? Ve? "Matches" ve "in" never ". .: Match any character other than the line break. (Pattern) matches the pattern and remembers the matching. The matched substring can be obtained from the matches set used as the result using item [0]... [N. To match the parentheses (and), use "\ (" or "\)". X | Y: matches X or Y. For example, "z | food" can match "Z" or "food ". "(Z | f) Ood" matches "Zoo" or "food ". {N}: N is a non-negative integer. Match exactly n times. For example, "O {2}" cannot match "O" in "Bob", but it can match the first two o in "foooood. {N ,}: N is a non-negative integer. Match at least N times. For example, "O {2,}" does not match "O" in "Bob", but matches all o in "foooood. "O {1,}" is equivalent to "O + ". "O {0,}" is equivalent to "O *". {N, m}: non-negative integers of M and N. Match at least N times, at most m times. For example, "O {1, 3}" matches the first three o in "fooooood. "O {0, 1}" is equivalent to "O? ". [Xyz]: A character set. Matches one of the characters in the brackets. For example, "[ABC]" matches "A" in "plain ". [^ XYZ]: A negative character set. Match any character that does not exist in this bracket. For example, "[^ ABC]" can match "p". [A-Z] in "plain": a character in a certain range. Matches any character in the specified range. For example, "[A-Z]" matches any lowercase letter between "A" and "z. [^ M-Z]: A negative character range. Matches a character that is not in the specified range. For example, "[M-Z]" matches any character that is not between "M" and "z. \ B: match the boundary of a word, that is, the position between a word and a space. For example, "Er \ B" matches "er" in "never", but does not match "er" in "verb ". \ B: matches non-word boundary. "EA * r \ B" matches "ear" in "never early. \ D: matches a number character. It is equivalent to [0-9]. \ D: matches non-numeric characters. It is equivalent to [^ 0-9]. \ F: match with the paging character. \ N: match the linefeed character. \ R: matches the carriage return character. \ S: matches with any white characters, including spaces, tabs, and pagination characters. It is equivalent to "[\ f \ n \ r \ t \ v]". \ S: matches any non-blank characters. It is equivalent to "[^ \ f \ n \ r \ t \ v]". \ T: matches the tab. \ V: match the vertical tab. \ W: matches any word characters, including underscores. It is equivalent to "[A-Za-z0-9 _]". \ W: matches any non-word characters. It is equivalent to "[^ A-Za-z0-9 _]". \ Num: matches num, where num is a positive integer. Reference back to the remembered match. For example, "(.) \ 1" matches two consecutive identical characters. \ N: Match n, where n is an octal value. The octal value must be 1, 2, or 3 characters long. For example, "\ 11" and "\ 011" Both match a tab. "\ 0011" is equivalent to "\ 001" and "1 ". The octal value cannot exceed 256. Otherwise, only the first two characters are considered part of the expression. ASCII code can be used in regular expressions. \ Xn: matches n, where n is a hexadecimal value. The hexadecimal value must be exactly two digits long. For example, "\ x41" matches "". "\ X041" is equivalent to "\ x04" and "1 ". ASCII code can be used in regular expressions.

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.