Please enable JavaScript.
Coggle requires JavaScript to display documents.
Part II:Automating Tasks 7 Pattern Matching with Regular Expressions…
Part II:Automating Tasks
7
Pattern Matching with Regular Expressions
More Pattern Matching with Regular Expressions 152
Grouping with Parentheses 152
Matching Multiple Groups with the Pipe 153
Optional Matching with the Question Mark . 154
Matching Zero or More with the Star 155
Matching One or More with the Plus 155
Matching Specific Repetitions with Curly Brackets 156
Greedy and Nongreedy Matching 156
The findall() Method 157
Character Classes . 158
Making Your Own Character Classes 159
The Caret and Dollar Sign Characters . 159
Practice Projects 171
Strong Password Detection 171
Project: Phone Number and Email Address Extractor . 165
Step 1: Create a Regex for Phone Numbers 166
Step 2: Create a Regex for Email Addresses 166
Step 3: Find All Matches in the Clipboard Text 167
Step 4: Join the Matches into a String for the Clipboard 168
Running the Program 169
Ideas for Similar Programs 169
The Wildcard Character 160
Matching Everything with Dot-Star 161
Matching Newlines with the Dot Character . 162
Review of Regex Symbols . 162
Case-Insensitive Matching 163
Finding Patterns of Text Without Regular Expressions . 148
Finding Patterns of Text with Regular Expressions 150
Creating Regex Objects . 150
Matching Regex Objects 151
Review of Regular Expression Matching 152
Summary . 169
Practice Questions . 170
Substituting Strings with the sub() Method . 163
Managing Complex Regexes 164
Combining re.IGNORECASE, re.DOTALL, and re.VERBOSE . 164