Here are some examples of possible regular expressions:/^ \ [\ t] * $/"^ \ [\ t] * $" matches a vacant row. /\ D {2}-\ d {5}/"\ d {2}-\ d {5}" verify that an ID number consists of two characters, A hyphen and a five-digit combination. /(. *). * \/\ 1/
Here are some examples of regular expressions that may be encountered:
/^ \ [\ T] * $/'^ \ [\ t] * $' matches a vacant row.
/\ D {2}-\ d {5}/'\ d {2}-\ d {5}' verify that an ID number consists of two characters, A hyphen and a five-digit combination.
/<(. *)>. * <\/\ 1>/'<(. *)>. * <\/\ 1>' matches an HTML tag.
The following table shows a complete list of metacharacters and their actions in the context of a regular expression:
Character Description
\ Mark the next character as a special character, a literal character, a back reference, or an octal escape character. For example, 'n' matches the character 'n '. '\ N' matches a line break. The sequence '\' matches '\' and '\ (' matches '('.
^ Matches the starting position of the input string. If the Multiline attribute of the RegExp object is set, ^ matches the status after '\ n' or' \ r.
$ Matches the end position of the input string. If the Multiline attribute of the RegExp object is set, $ also matches the status before '\ n' or' \ r.
* Matches the previous subexpression zero or multiple times. For example, zo * can match 'Z' and 'zoo '. * Is equivalent to {0 ,}.
Match the previous subexpression once or multiple times. For example, 'zo' can match 'zo' and 'zoo', but cannot match 'Z '. It is equivalent to {1 ,}.
? Match the previous subexpression zero or once. For example, 'Do (es )? 'Can match 'do' or 'Do 'in 'does '.? It is equivalent to {0, 1 }.
{N} n is a non-negative integer. Match n times. For example, 'O {2} 'cannot match 'O' in 'Bob', but can match two o in 'food.
{N,} n is a non-negative integer. Match at least n times. For example, 'O {2,} 'cannot match 'O' in 'Bob', but can match all o in 'foooood. 'O {1,} 'is equivalent to 'O '. 'O {0,} 'is equivalent to 'O *'.
Both {n, m} m and n are non-negative integers, where n <= m. Match at least n times and at most m times. Liu, 'O {1, 3} 'will match the first three of 'fooooood. 'O {0, 1} 'is equivalent to 'O? '. Note that there must be no space between a comma and two numbers.
? When this character is followed by any other delimiter (*,,?, The matching mode after {n}, {n ,}, {n, m}) is not greedy. The non-greedy mode matches as few searched strings as possible, while the default greedy mode matches as many searched strings as possible. For example, for strings 'Oooo ', 'o? 'Will match a single 'O', while 'O' will match all 'o '.
. Match any single character except '\ n. To match any character including '\ n', apply the mode like' [. \ n.
(Pattern) matches pattern and obtains this match. The obtained match can be obtained from the generated Matches aggregation. SubMatches clustering is applied to VBScript, and $0… is applied to Visual Basic Scripting Edition... $9 attribute. To match the parentheses, apply '\ (' or '\)'.
(? : Pattern) matches pattern but does not obtain the matching result. that is to say, this is a non-acquisition match and will not be stored for future applications. This is useful when 'or' character (|) is used to combine various parts of a pattern. For example, 'industr (? : Y | ies) is a simpler expression than 'industry | industries.