In 1951, mathematician Stephen Cole Kleene described the concept of a regular language, a language that is recognizable by a finite automaton and formally expressible using regular expressions. Remove ads A (Very Brief) History of Regular Expressions But once you get comfortable with it, you’ll find regexes almost indispensable in your Python programming.
How to create complex matching pattern with regex metacharactersįasten your seat belt! Regex syntax takes a little getting used to.How to use re.search() to match a pattern against a string.How to access the re module, which implements regex matching in Python.
At times, though, you may need more sophisticated pattern-matching capabilities. String matching like this is a common task in programming, and you can get a lot done with string operators and built-in methods. You can test whether one string is a substring of another with the in operator or the built-in string methods. You can test whether two strings are equal using the equality ( =) operator.
Since then, you’ve seen some ways to determine whether two strings match each other: A regex is a special sequence of characters that defines a pattern for complex string-matching functionality.Įarlier in this series, in the tutorial Strings and Character Data in Python, you learned how to define and manipulate string objects. In this tutorial, you’ll explore regular expressions, also known as regexes, in Python. Watch it together with the written tutorial to deepen your understanding: Regular Expressions and Building Regexes in Python Watch Now This tutorial has a related video course created by the Real Python team.