The basic metacharacter set of the Regular Expression and Its Meaning (lower). The character set of the regular expression.
|
Pattern \ {n \} |
|
Used to match the occurrence times of the previous pattern. N is the number of times |
All tools |
|
Pattern \ {n, \} m |
|
The meaning is the same as above, but the minimum number of times is n. |
All tools |
|
Pattern \ {n, m \} |
|
The meaning is the same as above, but pattern appears between n and m. |
All tools |
Note: The collection class operator [] indicates matching any character in. It can be a single character or a character sequence. You can also use-to indicate the range of character sequences in []. For example, use [1-5] instead of [12345].
What is a regular expression?
If you have never used a regular expression, you may not be familiar with this term or concept. However, they are not as novel as you think.
Remember how to find files on the hard disk. Are you sure you want to use? And * characters to help find the file you are looking .? Character matches a single character in the file name, while * matches one or more characters. A file such as 'data ?. The following files can be found in the dat mode:
Data1.dat
Data2.dat
Datax. dat
DataN. dat
If "*" is used instead? Characters to expand the number of files found. 'Data *. dat 'can match all the following file names:
Data. dat
Data1.dat
Data2.dat
Data12.dat
Datax. dat
DataXYZ. dat
Although this file search method is certainly very useful, it is also very limited .? The limited capabilities of wildcard and * enable you to define what a regular expression can do. However, regular expressions are more powerful and flexible.
Regular Expression * character put in front of what is the meaning, such as * [a-zA-Z0-9] * This is an example of a regular expression, the general metacharacter is not put behind
First *, the first one:
As far as I know, there is no such way of writing, that is, the syntax is wrong.
So the answer to this question is:
Or someone intentionally wrote an error to see if you know it is wrong.
If you are not familiar with the syntax, you will be wrong.
The second *, after the [a-zA-Z0-9]
First, you need to understand the meaning of the asterisks in the regular expression:
Match, 0 or more, with the regular expression above
And here the "regular above", you here is [a-zA-Z0-9]
So it means:
Match 0 or multiple letters and numbers
For more detailed explanations of asterisks, see what I wrote:
[Tutorial] detailed explanation of Python Regular Expression: '*' star matches 0 or multiple
(No post address is provided here. Please search the post title on google to find the post address)