Affiliate disclosure
Book titles on this page link to Amazon. As an Amazon Associate, DataField.Dev earns from qualifying purchases — at no additional cost to you.
Further Reading: Regular Expressions
Python Documentation
-
Python
remodule documentation. (Tier 1) https://docs.python.org/3/library/re.html The official reference for Python's regex engine. Comprehensive and precise, though dense. Bookmark this — you'll return to it regularly. -
Python Regular Expression HOWTO. (Tier 1) https://docs.python.org/3/howto/regex.html A more tutorial-oriented guide from the Python docs. Written by A.M. Kuchling, it's one of the best introductions available. Covers everything in this chapter and more, with clear examples.
Interactive Tools
-
regex101.com (Tier 1) https://regex101.com The best interactive regex tester. Paste a pattern and test string, and it highlights matches in real time, explains each part of the pattern in plain English, and shows capture groups. Select "Python" as the flavor for Python-specific behavior. Essential for learning and debugging regex.
-
RegExr (Tier 1) https://regexr.com Another excellent interactive tool with a built-in cheat sheet, community patterns, and detailed explanations. Good alternative to regex101.
Books
-
Friedl, J. E. F. (2006). Mastering Regular Expressions, 3rd Edition. O'Reilly Media. (Tier 1) The definitive book on regex. Goes far deeper than this chapter — covers regex engine internals, performance optimization, and advanced features across multiple languages. Recommended if you work with regex professionally.
-
Fitzgerald, M. (2012). Introducing Regular Expressions. O'Reilly Media. (Tier 1) A gentler introduction than Friedl's book. Good for reinforcing the concepts from this chapter at a comfortable pace. Language-agnostic, with examples in several languages including Python.
Practical Applications
-
Sweigart, A. Automate the Boring Stuff with Python, Chapter 7: "Pattern Matching with Regular Expressions." (Tier 1) A practical, project-focused treatment of regex in Python. Available free online. Good complement to this chapter — covers similar ground with different examples.
-
Goyvaerts, J. & Levithan, S. (2012). Regular Expressions Cookbook, 2nd Edition. O'Reilly Media. (Tier 1) A problem-solution format: presents common text processing tasks and shows the regex pattern for each. Covers email validation, date parsing, URL matching, and dozens more. Great as a reference you reach for when facing a specific task.
Theory and History
-
Thompson, K. (1968). "Programming Techniques: Regular expression search algorithm." Communications of the ACM, 11(6), 419-422. (Tier 1) The foundational paper where Ken Thompson described how to compile regular expressions into efficient machine code. Historical interest — this is where it all started.
-
Cox, R. (2007). "Regular Expression Matching Can Be Simple And Fast." (Tier 1) https://swtch.com/~rsc/regexp/regexp1.html An influential article explaining why some regex implementations (including Python's) can be exponentially slow on certain patterns, and how Thompson's original algorithm avoids this. Relevant to the ReDoS research exercise.
For the Curious
-
The
regexthird-party module. (Tier 2) https://pypi.org/project/regex/ A drop-in replacement forrewith additional features: Unicode property support, atomic groups, possessive quantifiers, and better performance on some patterns. Worth exploring if you outgrow the standard library. -
Regex Crossword (Tier 2) https://regexcrossword.com A game where you solve crossword-style puzzles using regex patterns. Surprisingly addictive and genuinely effective for building pattern-matching intuition.