Half an hour proficient in regular expression-Elite version _ Regular expression

Source: Internet
Author: User
Tags lowercase

Although the cloud-dwelling community has previously made a lot of regular expression tutorials, but this article is still good, no nonsense are more practical, the premise is that you need to understand the point of the regular expression before, or first look at some basic regular expression tutorial is better.

-------------------------------------------------------------------------^ and $ are used to match the start and end of a string, respectively------------------- 
------------------------------------------------------Example 1 ^<b> must be preceded by a "<b>" string; 
Example 2 </b>$ end must have "</b>" string; Example 3 ^abc$ A string that begins with ABC and ends with ABC, and is actually the only ABC-matched example 4 ABC does not match a string containing ABC without a symbol------------------------------------------------------ -------------------* + and? Used to indicate the number or order in which a character can occur. They represent-------------------------------------------------------------------------{0,} = * Example 1 ab{0, which matches the occurrence of the o-n times after the beginning of a (" A "," AB "," ABB "," abbbbbbbbbbbbbbbbb ", infinite ... {1,} = + Example 2 Ab{1,} matches with 1-n ("AB", "ABB", "abbbbbbbbbbbbbbbbb", infinite ...) after the beginning of a. ) {0,1}=? The example 3 ab{0,1} matches a string that appears O-1 ("A", "AB") a{0,1}b+$ matches 0 or 1 a plus a b at the end of a.
("B", "AB") Note (2 kinds of writing) ab{0, can also be written as ab* Ab{1, can also be written as ab+ ab{0,1} can also be written as AB? A{0,1}b+$ can also be written as a?b+$ (1) 1 points, ' * ' + ', and '? ' 
  Just control the number of occurrences of the character in front of it. 
2 {N,n} several times {0} o times 3{} This cannot be negative (2) times can be modified 5 ab{2} Requirements a must be followed by two B ("ABB"); Example 6 ab{2, require a must have two after aOr more than two B ("ABB", "abbbb", etc.); 

Example 7 ab{3,5} requires that a 2-5 B ("abbb", "abbbb", or "abbbbb") be followed by a. (3) followed by a number of characters used () example 8 A (BC) * Match a followed by 0 or a "BC"; 

Of course you can also write "a (BC) {0,}" Example 9 A (BC) {1,5} matches 1 to 5 "BC." -------------------------------------------------------------------------│ is equivalent to or used to represent 1 or more or------------------- 
------------------------------------------------------Example 1 a│b matches a string containing "A" or "B"; 
Example 2 (a│b) C matches a string containing "AC" or "BC";  Example 3 (a│b) *c match contains (including 0-1) A or B, followed by a C-------------------------------------------------------------------------. Can represent all the single characters-------------------------------------------------------------------------.

Excluding "\ n" spaces with a space and a character [\ n.] Multiple spaces +1 characters [\n\n\n\n\n\n.] Example 1 A.[0-9] a plus one character plus a number 0 to 9 for example 2 ^. {3}$ Three any character ends-------------------------------------------------------------------------' [ab] ' the bracketed content matches only one single character- 
------------------------------------------------------------------------Example 1 [ab] matches a single A or B (as with "a│b"); Example 2 [a-d] matches a single character of ' A ' to ' d ' (and "a│b│c│d" and "[ABCD]""The effect is the same); In general, we use [a-za-z] to specify the character as a case in English example 3 ^[a-za-z] Match string Example 4 with uppercase and lowercase letters [0-9]% matches a string example 5 with a value of x, [a-za-z0-9]$ matches a character that ends with a comma plus a number or letter 

String Example 6%[^a-za-z]% matches a string containing a (non) letter in the two percent sign. You can also put the characters you don't want in the brackets, you just need to use the ' ^ ' Essentials 1:^[content in the parentheses ^ outside the [] opening, 2:[^ content at the beginning of the content] ^ in [], it means excluding the contents (^ non-meaning) point 3: Matches the string containing these characters. In the brackets [*\+?{}.] or the ' symbol will fail parentheses only match single character points 4: [] It is best to use it as the first character in the list (possibly following the ' ^ ') point 5: [] contains the '-' preferably put it on the front or the last side, or a range of the second knot

 

The beam point [a-d-0-9] in the middle of '-' will be valid. -------------------------------------------------------------------------\b and \b 1 match a word right boundary 2 matches a non word boundary-------------- -----------------------------------------------------------Example 1 ' ve\b ': Can match Love's ve without matching very have VE case 2 ' ov\b ': Can match the OV in love and not match the Ovry ov-------------------------------------------------------------------------\d and \d-------- -----------------------------------------------------------------Example 1 \d matches a numeric character. 
equivalent to [0-9]. Example 2 \d matches a non-numeric character. 

equivalent to [^0-9]. -------------------------------------------------------------------------\w and \w-------------------------------------------------------------------------Example 1 \w matches any word character that includes an underscore. Equivalent to ' [a-za-z0-9_] ' Example 2 \w matches any non-word character that includes an underscore. 

Equivalent to ' [^a-za-z0-9_] '. -------------------------------------------------------------------------Match non-printing characters------------------------------- The------------------------------------------character meaning \cx matches the control character indicated by X. For example, \cm matches a control-m or carriage return character. The value of x must be one-a-Z or a-Z. 
Otherwise, c is treated as a literal ' C ' character. \f matches a page feed character. 
Equivalent to \x0c and \CL. \ n matches a newline character. 
Equivalent to \x0a and \CJ. \ r matches a carriage return character. 
Equivalent to \x0d and \cm. \s matches any white space character, including spaces, tabs, page breaks, and so on. 
equivalent to [\f\n\r\t\v]. \s matches any non-white-space character. 
equivalent to [^ \f\n\r\t\v]. \ t matches a tab character. 
Equivalent to \x09 and \ci. \v matches a vertical tab. 

Equivalent to \x0b and \ck. -------------------------------------------------------------------------Example------------------------------------ -------------------------------------a regular expression that matches the ^s*|s*$: the regular expression that matches the email address: w+ ([-+.] w+) *@w+ ([-.] w+) *.w+ ([-.] w+) * Matching the URL of the regular expression: [a-za-z]+://[^s]* matching account is legitimate (the beginning of the letter, allow 5-16 bytes, allow alphanumeric underline): ^[a-za-z][a-za-z0-9_]{4,15}$ matching domestic phone number: d{3} -D{8}|D{4}-D{7} match form such as 0511-4405222 or 021-87888822 920-209 642-964 match Tencent QQ number: [1-9][0-9]{4,} 1+ after four for the start of the number, that is, 10000 matching china zip code: [1-9]d{5} (?!) D China Postal Code is 6 digits matching ID: d{15}|d{18} commentary: China's ID card is 15-bit or 18-bit matching IP address: d+.d+.d+.d+ Commentary: It is useful to extract an IP address---------------------------------  ----------^ $//start to end +//continuous 1-n (ie-{1,})-?  Represents a negative and non-negative (that is,-{0,1}) [0-9]*//Represents the previous number of digits 0-n (that is, [0-9]{0,}). Denotes a bit or no point [^//non inside content [A-z]//Match all lowercase letters [a-z]//Match all uppercase letters [A-ZA-Z]///Match all the letters [0-9]///Match all numbers 0-9 integers [0-9.-]//Match all numbers Words, periods, and minus signs------------------------------------------------^[a-za-z0-9_]+$//All the strings containing more than one letter, number, or underline//examples are connected together aa0_ A001a_ ^[0-9]+$//All positive numbers (also can be said to be non-negative integers)//Give example 345500687008099900999 ^-? [0-9]+$//all integers (including negative integers and integers)//example-43443 or 43443 ^-? [0-9]*.? [0-9]*$//all decimals (including the number of digits before and after decimal decimal points are infinitely long)//example-10.00 or 100000.0000 If there is no number after the decimal point, then add a front. To determine whether there are small points, according to the truth can not be required. 
 Is superfluous because this is a special judge of decimal, if there is no decimal point, is it still called pay? [^a-z]//All characters except lowercase letters [^/^]//All characters except "/" and "^" characters [^ "]//except double quotes (") and single quotes (')

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.