1. "." Is a wildcard, indicating any character, for example: "ac" can match "ANC", "ABC", "ACC"; 2, "[]", in [], you can specify the matching character, For example: "A [NBC] C" can match "ANC", "ABC", "ACC"
But can not match "ANCC", A to Z can be written into [A-Z], 0 to 9 can be written into [0-9];
3, quantity defined symbol, indicating the number of matching times (or length):
Including: "*" - 0 times or " " - 1 time or multiple "?" - 0 times or 1 "{n}" - match N times, N is integer "{n, M} "- Match a number of times from N to M; N and M are integers;" {n,} "- match the number of N to infinity;" {, m} " - Match 0 to m Any number of times; they put them behind the matching format: for example: phone number: 024-84820482, 02484820482 (assuming the front 3 or 4 bits, the back 7 or 8, and the middle decline can be None)
They are all compliant, then they can be used in the following format: [0-9] {3, 4} / -? [0-9] {7,8}; note: "/" For the escape character, because " - "In the regular expression, there is a scope of meaning, such as:" [0-9] mentioned earlier,
So it needs to escape characters "/" to use; 4, "^" is indicator, indicating that the symbols do not want to match, for example: [^ z] [AZ] can match all "Z" starting All words outside
String (length is greater than 2, because " " means more than equal to 1, from the second bit is lowercase English characters); if ^ is placed outside [], it indicates the string starting with []; ^ [ AZ] [AZ] represents the length of the length of A or Z is greater than or equal to 2
Strings; 5, "|" or operators, for example: a [N | BC | CB] c can match "ABCC", "ANC", "ACBC"; 6, "$" at the end of its previous characters; for example : AB $ can be matched by "abb", "ab"; 7, some simple representation: / D indicate [0-9]; / D indicate [^ 0-9]; / W Representation [A-Z0-9 ]; / W Represents [^ a-z0-9]; / s represents [/ t / n / r / f], that is, space characters include Tab
, Space, etc.; / s represents [^ / T / N / R / F], is a non-space character; 8, common match: match Chinese characters: "[/ u4e00- / u9fa5]"; match Double-character character (Including Chinese characters): "[^ / X00- / XFF]"; Regular expression of matching blank line: "/ n [/ s |] * / r"; regular expression that matches HTML tag: "/ < (. *)>. * // 1> | <(. *) //> / "; Regular expression of matching the first tail space:" (^ / s *) | (/ s * $) "; match Non-negative integer (positive integer 0): "^ / d $"; match positive integer: "^ [0-9] * [1-9] [0-9] * $"; matching non-positive integer (negative integer 0): "^ ((- / d ) | (0 )) $"; matching negative: "^ - [0-9] * [1-9] [0-9] * $"; match integer : "^ -? / D $"; match the number of non-loot points (positive floating point 0): "^ / d (/ d )?" Matches the positive floating point: "^ ((([0-9] /. [0-9] * [1-9] *) | ([0-9] * [1-9] [0-9] * /. [0-9] ) | ([0-9] * [1-9] [0-9] *)) $ "; ^ ((((((((((0 (/ d )?) | (0 (/. 0 )?)) $ // Match non-positive floating point numbers (12-9] /. [0-9] * [1-9] [0-9] *) | ([0) -9] * [1-9] [0-9] * /. [0-9] * [1-9] [0-9] *))) $ // Match
Endo points match floating point number: "^ (-? / D ) (/. / d )? $"; Matching string consisting of numbers, 26 English letters or underscores: "^ / w $"; match Email address : "^ [/ W -] (/. [/ W -] ) * @ [/ w -] (/. [/ W -] ) $"; Match URL: "^ [A-ZA -z] : // Match (/W (-/w ) * (/.(/w (-/w ) * * (/?/s*)? "