The subject of regular expressions is quite deep, and it takes an immense amount of practice to get used to the special character syntax. Furthermore, the re module contains a vast set of methods available for performing searches using regular expressions. Upon completing the examples in this section, you should have a much deeper appreciation for how powerful regular expressions can be.
An even more compact representation uses escape codes for several predefined character sets. The escape codes recognized by
re are listed in the table below.
||whitespace (tab, space, newline, etc.)|
These sample expressions combine escape codes with repetition to find sequences of like characters in the input string.
To match the characters that are part of the regular expression syntax, escape the characters in the search pattern.
The pattern in this example escapes the backslash and plus characters, since both are meta-characters and have special meaning in a regular expression.