About the Tutorial


Grouping with Parentheses



Download 2,85 Mb.
Pdf ko'rish
bet232/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   226   227   228   229   230   231   232   233   234
Bog'liq
python3 tutorial 060821094426

Grouping with Parentheses 
Example 
Description 
\D\d+ 
No group: + repeats \d 
(\D\d)+ 
Grouped: + repeats \D\d pair 
([Pp]ython(, )?)+ 
Match "Python", "Python, python, python", etc. 


Python 3 
356 
Backreferences 
This matches a previously matched group again- 
Example 
Description 
([Pp])ython&\1ails 
Match python&pails or Python&Pails 
(['"])[^\1]*\1 
Single or double-quoted string. \1 matches whatever the 1st 
group matched. \2 matches whatever the 2nd group matched
etc. 
Alternatives 
Example 
Description 
python|perl 
Match "python" or "perl" 
rub(y|le)) 
Match "ruby" or "ruble" 
Python(!+|\?) 
"Python" followed by one or more ! or one ? 
Anchors 
This needs to specify match position. 
Example 
Description 
^Python 
Match "Python" at the start of a string or internal line 
Python$ 
Match "Python" at the end of a string or line 
\APython 
Match "Python" at the start of a string 
Python\Z 
Match "Python" at the end of a string 
\bPython\b 
Match "Python" at a word boundary 
\brub\B 
\B is nonword boundary: match "rub" in "rube" and "ruby" but not 
alone 


Python 3 
357 
Python(?=!) 
Match "Python", if followed by an exclamation point. 
Python(?!!) 
Match "Python", if not followed by an exclamation point. 
Special Syntax with Parentheses 
Example 
Description 
R(?#comment) 
Matches "R". All the rest is a comment 
R(?i)uby 
Case-insensitive while matching "uby" 
R(?i:uby) 
Same as above 
rub(?:y|le)) 
Group only without creating \1 backreference 


Python 3 
358 
The Common Gateway Interface, or CGI, is a set of standards that define how information 
is exchanged between the web server and a custom script. The CGI specs are currently 
maintained by the NCSA and NCSA. 

Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   226   227   228   229   230   231   232   233   234




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish