diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 1aefb91e0ceb405..3fad93a060c29f7 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1483,8 +1483,8 @@ Since :meth:`~Pattern.match` and :meth:`~Pattern.search` return ``None`` when there is no match, you can test whether there was a match with a simple ``if`` statement:: - if match := re.search(pattern, string): - process(match) + if m := re.search(pattern, string): + process(m) .. class:: Match @@ -1707,10 +1707,10 @@ Checking for a pair In this example, we'll use the following helper function to display match objects a little more gracefully:: - def displaymatch(match): - if match is None: + def displaymatch(m): + if m is None: return None - return '' % (match.group(), match.groups()) + return '' % (m.group(), m.groups()) Suppose you are writing a poker program where a player's hand is represented as a 5-character string with each character representing a card, "a" for ace, "k"