Learn re
Regular expressions for searching, validating, extracting and rewriting text
The re module implements Perl-style regular expressions for Python strings and bytes. You use it to find patterns in text, validate formats, pull structured fields out of logs or documents, split on complex separators and perform rule-based replacements. Knowing it well also means knowing its limits: readability, Unicode details and catastrophic backtracking.
Before you start
How deep do you want to go?
1. EssentialsRead and write simple code, do the everyday basics
2. PracticalUse it productively at work, with the usual idioms
3. AdvancedThe less common features, performance and trade-offs
4. ExpertInternals and the edge cases experts know