A regular expression (regular exprssion) is a text match pattern described by a formal syntax. The mode is interpreted as a group of commands, and then the group of commands is executed. Use a string as the input to generate a matching subset or a modified version of the source string.
Expressions can include literal text matching, repetition, mode combination, and other complex rules at the branch level.
- Search for patterns in text
The most common usage of re is to search for the mode in text. The search () function uses the pattern and text of the sample code as the input. If this pattern is found, a Match object is returned. If None is found, None is returned.
=====%
Group () shows the matched string
Start () end () indicates the position where the text matching the pattern appears in the string.
Found 5 to 9 ()
You can also use the span () function to return the position of the matched string (match. span ())