| Method |
Return |
Parameters |
Description |
| . Compile () |
Regex |
Compiling a regular expression pattern into a regular expression object |
| Pattern |
Regular expressions |
| Flags=0 |
Adjusts the behavior of an expression, which can be combined using the OR (|) |
| . A |
flags= |
Let,,,,,, and \w perform a \W \b \B \d \D \s \S pure ASCII match instead of all Unicode matches (meaning only in Unicode mode, and in byte mode is ignored) |
| . Ascii |
| . DEBUG |
flags= |
To display debugging information about a compilation expression |
| . I |
flags= |
Perform a case-insensitive match |
| . IGNORECASE |
| . L |
flags= |
It is not recommended to use??? |
| . LOCALE |
| . M |
flags= |
Make ^ $ match the beginning and end of each line, not just the beginning and end of the entire string (^ matches the position immediately following the newline character). $ matches the position immediately before the line break |
| . MULTILINE |
| . S |
flags= |
Let. You can also match to a newline character (default. Smart match characters other than line breaks) |
| . Dotall |
| . X |
flags= |
A more friendly editing mode ignores whitespace characters in regular expressions and the non-escaped # numbers and the contents of the same line, so that you can edit regular expressions in multiple lines, which is more useful for reading |
| . VERBOSE |
| . Search () |
Match
None |
Returns the result of the first match, no match returns none |
| Pattern |
Regular expressions |
| String |
The string to match |
| Flags=0 |
Invoking the behavior of an expression |
| . Match () |
. Search () |
can only match from the beginning of a string |
| . Fullmatch () |
. Search () |
Regular expression matches entire string 3.4 |
| . Split () |
List |
Use regular expressions to split a string, returning a segmented list of strings (capture is also included in the result if a capturing group is contained) |
| Pattern |
Regular expressions |
| String |
The string to match |
| Maxsplit=0 |
Maximum number of splits |
| Flags=0 |
Invoking the behavior of an expression |
| . FindAll () |
List |
. Search () |
Return all matching results as a list |
| . Finditer () |
Iter |
. Search () |
Returns an iterator that contains all matching results |
| . Sub () |
Str |
Replace the matched string with REPL |
| Pattern |
Regular expressions |
| Repl |
STR, fun (match): return str |
| String |
The string to match |
| Count=0 |
Maximum number of allowable substitutions |
| Flags=0 |
Invoking the behavior of an expression |
| . SUBN () |
Tuple |
. Sub () |
return (substituted string, number of replacements) |
| . Escape () |
Str |
String |
Escapes all characters except ASCII letters, numbers, and ' _ ' (' _ ' 3.3 is no longer escaped) |
| . Purge () |
|
Clear the Regular expression cache |
| . Error () |
|
|
??? |
| Methods and properties of compiled regular expression objects |
| . Search () |
Match |
string[, pos[, Endpos]] |
| . Match () |
Match |
string[, pos[, Endpos]] |
| . Fullmatch () |
Match |
string[, pos[, Endpos]] |
| . Split () |
List |
String, maxsplit=0 |
| . FindAll () |
List |
string[, pos[, Endpos]] |
| . Finditer () |
Iter |
string[, pos[, Endpos]] |
| . Sub () |
Str |
REPL, String, count=0 |
| . SUBN () |
Tuple |
REPL, String, count=0 |
| . Flags |
Flags |
Regular expression matching flags |
| . Groups |
Int |
Number of capturing groups in the pattern |
| . groupindex |
Dict |
Will (? p<id>) defines a dictionary of any symbol group names mapped to group numbering |
| . pattern |
Str |
Compiling a pattern string for the RE object |
| Method of the Match object |
| . Expand () |
|
|
|
| . Group () |
Str |
0 |
Default, return matching results |
| Str |
1 |
Returns the content captured by the first capturing group |
| Tuple |
1, 2 |
Returns a tuple consisting of two capturing group contents |
| . Groups () |
Tuple |
Returns the contents of all capturing groups in tuples |
| Default=none |
If the capture group content is empty, this value is used to populate |
| . Groupdict () |
Dict |
Default=none |
A capturing group with name, returned as a dictionary |
| . Start () |
Int |
[Group] |
Where to start the match |
| . End () |
Int |
[Group] |
Where to end the match |
| . Span () |
Tuple |
[Group] |
(Match start position, match end not to) |
| . Pos |
|
The POS value passed |
| . endpos |
|
The Endpos value passed |
| . lastindex |
|
Integer index of the last capturing group |
| . lastgroup |
|
|
| . Re |
|
|
| . String |
|
The string to match |