September 2026
1051 pages
35h 4m
English
Depending on the application, regular expressions can become so complex in practice that their meaning isn’t readily apparent to the reader of the program. In such cases, it’s useful to use the VERBOSE flag of the re module. As described in Table 28.5, this flag ensures that all white space characters within the regular expression are ignored unless they are preceded by a backslash. This can be used to visually structure a regular expression by selectively inserting spaces and line breaks. As an example, let's consider the regular expression for finding links in HTML pages, as introduced in Section 28.3:
r"<a .*href=[\"\'](.*?)[\"\'].*>(.*?)</a>"
This expression can be used reformatted using the VERBOSE ...
Read now
Unlock full access