diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-12-16 23:17:17 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-12-16 23:17:17 (GMT) |
commit | e5b2ac898785ba78a6a81878d77d270fcb5fba61 (patch) | |
tree | f937c352b8b9f50ee5a54705e2cbd5ef8494303c /Doc/library/re.rst | |
parent | 94ba691ed34ffa1aff424876d6162b39a297e29e (diff) | |
download | cpython-e5b2ac898785ba78a6a81878d77d270fcb5fba61.zip cpython-e5b2ac898785ba78a6a81878d77d270fcb5fba61.tar.gz cpython-e5b2ac898785ba78a6a81878d77d270fcb5fba61.tar.bz2 |
#13613: fix example in re doc.
Diffstat (limited to 'Doc/library/re.rst')
-rw-r--r-- | Doc/library/re.rst | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 3dec04c..0c2c4fa 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1018,16 +1018,16 @@ objects a little more gracefully: 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" -for king, "q" for queen, j for jack, "0" for 10, and "1" through "9" +for king, "q" for queen, "j" for jack, "t" for 10, and "2" through "9" representing the card with that value. To see if a given string is a valid hand, one could do the following: - >>> valid = re.compile(r"[0-9akqj]{5}$") - >>> displaymatch(valid.match("ak05q")) # Valid. - "<Match: 'ak05q', groups=()>" - >>> displaymatch(valid.match("ak05e")) # Invalid. - >>> displaymatch(valid.match("ak0")) # Invalid. + >>> valid = re.compile(r"^[a2-9tjqk]{5}$") + >>> displaymatch(valid.match("akt5q")) # Valid. + "<Match: 'akt5q', groups=()>" + >>> displaymatch(valid.match("akt5e")) # Invalid. + >>> displaymatch(valid.match("akt")) # Invalid. >>> displaymatch(valid.match("727ak")) # Valid. "<Match: '727ak', groups=()>" |