Regular expression syntax A regular expression is a text mode composed of normal characters (such as characters a to z) and special characters (called metammatics). This mode describes one or more strings to be matched when the text body is looking for. Regular expression As a template, a character mode matches the search string. Here are some regular expressions that may be encountered: Visual Basic VBScript Match Scripting Edition / ^ / [/ T * $ / "^ / [/ t] * $" matches a blank line. // D {2} - / d {5} / "/ d {2} - / d {5}" verifies whether an ID number consists of a 2-bit word, a hyphen, and a 5-digit. /< (.*)>. (*)>. * // 1> "matches an HTML tag. The following table is a full list of metammatics and its behavior in the regular expression context: Character Description / Tags the next character as a special character, or a primary character, or a backward reference, or an octal escape symbol. For example, 'n' matches characters "n". '/ N' matches a newline. Sequence '//' match "/" "/ (" matches "(". ^ Match the input string of the start position. If the multiline property of the regexp object is set, ^ also matches '/ n' or '/ r' The next location. $ Match the end position of the input string. If the multiline property of the regexp object is set, $ also matches the position before '/ n' or '/ r'. * Match the previous sub-expression zero or multiple times For example, ZO * can match "Z" and "ZOO". * Equivalent {0,}. Match the previous sub-expression once or more. For example, 'ZO ' can match "ZO" and "ZOO" ", But do not match" Z ". Equivalent to {1,}. • Match the previous sub-expression zero or once. For example," Do (es) can match "do" or "does" "do". Is equivalent to {0,1}. {n} n is a non-negative integer. Match the N times. For example, 'o {2}' does not match 'O' in "Bob", but Match two O. {n,} n is a non-negative integer. For example, 'o {2,}' does not match "bob", but can match "at least N times. For example, 'o {2,}' does not match" Bob ". All O.'o {1,} 'in "fooood" is equivalent to' o 'o {0,}', equivalent to 'o *'. {n, m} m and n are non-negative Integer, where n <= m. Minimize n times and matched M times. Liu, "O {1, 3}" will match the top three O. 'o {0, 1}' in "foooood". Value 'o?'. Please note that there is no space between commas and two numbers? When this character is tight in any other restriction (*, ,?, {N}, {n,}, {n When M}), the matching mode is non-greedy. Non-greedy mode matches the search string as little as possible, and the default greed mode is as many as possible to match the search string.
For example, for the string "OOOO", 'o ?' Will match a single "O", and 'o ' will match all 'o'. Match any individual characters other than "/ n". To match any character, including '/ n', use the mode of the '[./n]'. (Pattern) Match Pattern and get this match. The acquired matches can be obtained from the generated Matches, using the Submatches collection in VBScript, using $ 0 ... $ 9 properties in Visual Basic Scripting Edition. To match the bracket characters, use '/ (' or '/)'. (?: Pattern) Match Pattern but does not acquire matching results, that is, this is a non-acquired match, not for storage. This is useful to use the "or" character (|) to combine a pattern. For example, 'industr (?: Y | iES) is a smale of' Industry | Industries'. (? = Pattern) Positive to check, match the lookup string at any string of Pattern. This is a non-acquisition match, that is, the match does not need to be used later. For example, 'Windows (? = 95 | 98 | NT | 2000) can match "Windows" in "Windows 2000", but cannot match "Windows" in "Windows3 .1". The forecast does not consume characters, that is, after a match occurs, start the next matching search immediately after the last match, not starting from the character containing the pre-check. (?! Pattern) negotiation, match the lookup string at any string of any mismatch at any Point WHERE A STRING NOT MATCHING POINT WHERE A STRING NOT MATCHING PATTERN. This is a non-acquired match, that is, the match does not need to be used later. For example, 'Windows (?! 95 | 98 | NT | 2000) "can match" Windows "in Windows 3.1, but cannot match" Windows "in" Windows 2000 ". The forecast does not consume characters, that is, after a match occurs, immediately start the next matching search immediately after the last match, instead of the X | Y, the X | Y is matched after the queue containing the pre-examined character. For example, 'Z | Food' can match "z" or "food". '(Z | f) OOD' matches "Zood" or "Food". [XYZ] Character collection. Match any of the included characters. For example, '[abc]' can match 'a' in "Plain". [^ XYZ] Negative character set. Match any of the characters that are not included. For example, '[^ ABC]' can match 'P' in "Plain". [A-Z] character range. Match any of the characters within the specified range. For example, '[a-z]' can match any lowercase letters character in the 'A' to 'Z' range. [^ A-z] Negative character range.
Match any of any characters that are not within the specified range. For example, '[^ a-z]' can match any of any characters that are not in the 'A' to 'Z'. / B Match a word boundary, that is, the location of the words and spaces. For example, 'er / b' can match 'ER' in "Never", but do not match 'Er' in "Verb". / B matches non-word boundary. 'ER / B' Match 'Er' in "Verb", but does not match 'Er' in "Never". / CX matches the control character indicated by x. For example, / cm matches a Control-M or a carrier. The value of x must be one of A-Z or A-Z. Otherwise, the C is treated as a protact 'c' character. / D Match a numeric character. Equivalent to [0-9]. / D Match a non-digital character. Equivalent to [^ 0-9]. / F Match a change page. Equivalent to / x0c and / cl. / N Match a newline. Equivalent to / x0a and / cj. / R Match a carriage return. Equivalent to / X0D and / cm. / S Match any blank character, including spaces, tabs, change page, and the like. Equivalent to [/ f / n / r / t / v]. / S Match any non-blank character. Equivalent to [^ / f / N / R / T / V]. / T matches a tab. Equivalent to / x09 and / ci. / V Match a vertical tab. Equivalent to / x0b and / ck. / W Match any word character that includes underscore. Equivalent to '[A-ZA-Z0-9_]'. / W Match any non-word characters. Equivalent to '[^ a-za-z0-9_]'. / XN matches n, where n is a hexadecimal escape value. The hexadecimal escape value must be a long two numbers. For example, '/ x41' matches "a". '/ X041' is equivalent to '/ x04' & "1". ASCII coding can be used in regular expressions. . / NUM matches NUM, where NUM is a positive integer. References to the acquired match. For example, '(.) / 1' matches two consecutive identical characters. / N identifies an octal escape value or a rearward reference. If the sub-expression of at least N before / N, n is a backward reference. Otherwise, if n is an octal number (0-7), then n is an eight-input escape value. / Nm identifies an octal escape value or a backward reference. If the / nm has at least IS Preceded by Least NM acquired a sub-expression, the nm is a backward reference. If there is at least n acquisition before / nm, then n is a rear reference reference of a post-written word M. If the previous conditions are not satisfied, if n and m are octal numbers (0-7), the / nm will match the eight-way escape value Nm. / NML If n is an octal number (0-3), and M and L are eight-input numbers (0-7), match the eight-en-enamded escape value NML. / UN matches N, where N is a Unicode character represented by four hexadecimal numbers. For example, / u00A9 matches copyright symbol (?).
"^ / D $" // Non-negative integer (positive integer 0) "^ [0-9] * [1-9] [0-9] * $" // 正 整 "" ^ ((- / d ) | (0 )) $ "// Non-positive integer (negative integer 0)" ^ - [0-9] * [1-9] [0-9] * $ "// negative integer" ^ -? / D $ "// integer" ^ / D (/. / D ) $ "// Non-looted number (positive floating point 0)" ^ (([0-9] /. [0-9] * [1-9] *) | ([0-9] * [1-9] [0-9] * /. [0-9] ) | ([0-9] * [1 -9] [0-9] *)) $ "正 正 floating point number" ^ ((- / D (/ d )?) | (0 (/. 0 )?)) $ "// Non-positively floating point (12 0) "^ ((([([0-9] /. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] * /. [0-9] ) | ([0-9] * [1-9] [0-9] *))) $ "// loaded point number "^ (-? / d )? $" // floating point number "^ [A-ZA-Z] $" // String consisting of 26 English letters "^ [AZ] $ "// String consisting of 26 English letters" ^ [AZ] $ "// String of 26 English letters," ^ [A-ZA-Z0-9] $ " // String "^ / W $" // consisting of numbers, 26 English letters or underscores "^ [/ w -] (/ w-] ) * @ [/ w -] (/. [/ w -] ) $ "// email address" ^ [A-ZA-Z] : // (/ w (- / w ) *) (/.(/w (-/w ) * * * (/?/s*)? "// url / ^ (D {2} | D {4}) - ((0 ([1-9 ] {1})) | (1 [1 | 2])) - (([0-2] ([1-9] {1}) | (3 [0 | 1])) $ / // year - Month - Japan / ^ ((0 (1-9] {1}) | (1 [1 | 2])) / (([0-2] ([1-9] {1}) | (3 [0 | 1])) / (D {2} | d {4}) $ / / month / day / year "^ ([w -.] ) @ (([0-9] { 1, 3}. [0-9] {1,3}. [0-9] {1,3}.) | ([W -] .) )) ([A-ZA-Z] { 2, 4} | [0-9] {1,3} (]?) $ "// EMIL" (D {4} -? D {7} | d {3 } -? D {8} | ^ D {7,8}) (- D )? "// Phone Number" ^ (D {1, 2} | 1DD | 2 [0-4] D | 25 [0- 5]). (D {1, 2} | 1DD | 2 [0-4] D | 25 [0-5]). (D {1, 2} | 1DD | 2 [0-4] D | 25 [ 0-5]). (D {1, 2} | 1DD | 2 [0-4] D | 25 [0-5]) $ "// ip address ^ ([0-9A-f] {2}) (- [0-9A-F] {2}) {5} $ // MAC address regular expressions ^ [- ]? / D (/. / D )? $ // value type regular expression