Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
e5b2ac89
Kaydet (Commit)
e5b2ac89
authored
Ara 16, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#13613: fix example in re doc.
üst
94ba691e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
re.rst
Doc/library/re.rst
+6
-6
No files found.
Doc/library/re.rst
Dosyayı görüntüle @
e5b2ac89
...
@@ -1018,16 +1018,16 @@ objects a little more gracefully:
...
@@ -1018,16 +1018,16 @@ objects a little more gracefully:
Suppose you are writing a poker program where a player's hand is represented as
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"
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.
representing the card with that value.
To see if a given string is a valid hand, one could do the following:
To see if a given string is a valid hand, one could do the following:
>>> valid = re.compile(r"
[0-9akqj
]{5}$")
>>> valid = re.compile(r"
^[a2-9tjqk
]{5}$")
>>> displaymatch(valid.match("ak
0
5q")) # Valid.
>>> displaymatch(valid.match("ak
t
5q")) # Valid.
"<Match: 'ak
0
5q', groups=()>"
"<Match: 'ak
t
5q', groups=()>"
>>> displaymatch(valid.match("ak
0
5e")) # Invalid.
>>> displaymatch(valid.match("ak
t
5e")) # Invalid.
>>> displaymatch(valid.match("ak
0
")) # Invalid.
>>> displaymatch(valid.match("ak
t
")) # Invalid.
>>> displaymatch(valid.match("727ak")) # Valid.
>>> displaymatch(valid.match("727ak")) # Valid.
"<Match: '727ak', groups=()>"
"<Match: '727ak', groups=()>"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment