Syntax format: Between delimiters. 1 Common metacharacters include: +, *, and ?. The + metacharacter specifies that the leading character must appear one or more times consecutively in the target object. * The metacharacter specifies that the leading character must appear zero or multiple times consecutively in the target object, and? Metacharacter specifies that its leading object must be connected to the target object
Syntax format: Between the delimiters. 1 Common metacharacters include: +, *, and ?. The + metacharacter specifies that the leading character must appear one or more times consecutively in the target object. * The metacharacter specifies that the leading character must appear zero or multiple times consecutively in the target object, and? Metacharacter specifies that its leading object must be connected to the target object
Syntax format:Between the delimiters.
1 Common metacharacters include "+", "*", and "?".
Where,
The "+" metacharacter specifies that its leading character must appear one or more times consecutively in the target object,
The "*" metacharacter specifies that its leading character must appear zero or multiple times in the target object,
And "?" Metacharacter specifies that the leading object must appear zero or once consecutively in the target object.
1/jim {2, 6 }/
2 The above regular expression specifies that the character m can appear 2-6 times consecutively in the matching object. Therefore, the above regular expression can match strings such as jimmy or jimmm.pdf.
3. After a preliminary understanding of how to use regular expressions, let's take a look at the usage of several other important metacharacters.
4 \ s: Used to match a single space character, including the tab key and line break;
5 \ S: Used to match all characters except a single space character;
6 \ d: Used to match numbers from 0 to 9;
7 \ w: Used to match letters, numbers, or underscores;
8 \ W: Used to match all characters that do not match \ w;
9.: Used to match all characters except line breaks.
In addition:
Commonly used positioning characters include "^", "$", "\ B", and "\ B ".
The "^" Locator specifies that the matching mode must start with the target string,
The "$" operator specifies that the matching mode must appear at the end of the target object,
The \ B locator specifies that the matching mode must appear at either the beginning or end of the target string,
The "\ B" Locator specifies that the matched object must be within the boundary of the start and end of the target string. That is, the matched object cannot start with the target string, it cannot end with the target string.
Matches a specified range, not limited to specific characters. For example:
/[A-Z]/
The above regular expression will match any uppercase letter from A to Z.
/[A-z]/
The above regular expression will match any lowercase letter from a to z.
/[0-9]/
The above regular expression will match any number from 0 to 9.
/([A-z] [A-Z] [0-9]) +/