Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e5b2ac8

Browse files
committed
#13613: fix example in re doc.
1 parent 94ba691 commit e5b2ac8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Doc/library/re.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,16 +1018,16 @@ objects a little more gracefully:
10181018

10191019
Suppose you are writing a poker program where a player's hand is represented as
10201020
a 5-character string with each character representing a card, "a" for ace, "k"
1021-
for king, "q" for queen, j for jack, "0" for 10, and "1" through "9"
1021+
for king, "q" for queen, "j" for jack, "t" for 10, and "2" through "9"
10221022
representing the card with that value.
10231023

10241024
To see if a given string is a valid hand, one could do the following:
10251025

1026-
>>> valid = re.compile(r"[0-9akqj]{5}$")
1027-
>>> displaymatch(valid.match("ak05q")) # Valid.
1028-
"<Match: 'ak05q', groups=()>"
1029-
>>> displaymatch(valid.match("ak05e")) # Invalid.
1030-
>>> displaymatch(valid.match("ak0")) # Invalid.
1026+
>>> valid = re.compile(r"^[a2-9tjqk]{5}$")
1027+
>>> displaymatch(valid.match("akt5q")) # Valid.
1028+
"<Match: 'akt5q', groups=()>"
1029+
>>> displaymatch(valid.match("akt5e")) # Invalid.
1030+
>>> displaymatch(valid.match("akt")) # Invalid.
10311031
>>> displaymatch(valid.match("727ak")) # Valid.
10321032
"<Match: '727ak', groups=()>"
10331033

0 commit comments

Comments
 (0)