Your Turn: The caret symbol A matches the start of a string, just like the $ matches the end. What results do we get with the example just shown if we leave out both of these, and search for «..j..t..»?
Finally, the ? symbol specifies that the previous character is optional. Thus «Ae-?mail $» will match both email and e-mail. We could count the total number of occurrences of this word (in either spelling) in a text using sum(1 for w in text if re.search('Ae-? mail$', w)).
Was this article helpful?