SlideShare a Scribd company logo
Python
re
Алексей Бованенко
a.bovanenko@gmail.com
Python. re
● import re
● Regular expression
Python. re
● d D
● s S
● w W
● b
● []
○ [amk]
○ [0-5][0-9]
● '.'
● '^', '$'
● '*'
● '+'
● '?'
● {m}
● {m,n}
● (...)
● (?:...)
Python. compile
● compile(pattern, flags=0)
○ re.I¶
○ re.M¶
○ re.U
● r = re.compile(‘b(ddsd)’)
m = r.match(text)
Python. match
● match(pattern, string, flags=0)
● m=re.match(‘[a-z0-9_.-]+@[a-z0-9.-]+.w{2,4}’,text)
○ m - match object
○ m - None
○ m.group(n)
Python. findall
● findall(pattern, string, flags=0)
○ Return a list of all non-overlapping matches in the
string
○ Empty matches are included in the result
Python. findall
● text = ‘’’hello, my friend! 1234 Hello, world 1616
... It's time to understand 2323. Hiiiii! 4567 ooogh
... Good morning!!! 4345 heheheheh 5665 jfgjfjgjf 4545
... That's all!!!! 7878 7678 0990 9900 7878'''
● results = re.findall('(d{2})1',text)
Python. search
● search(pattern, string, flags=0)
○ match object
○ None if no match was found
● m = re.search('(d{2})1',text)
Python. finditer
● finditer(pattern, string, flags=0)
○ iterator over all non-overlapping matches
● iter = re.search('(d{2})1',text)
for m in iter:
... print m.group(0)
Спасибо за внимание
Вопросы?

More Related Content

What's hot (20)

PDF
Advanced
Logan Campbell
 
PPTX
Scoda openrefine-directordata
Tony Hirst
 
PDF
Py lecture5 python plots
Yoshiki Satotani
 
PDF
Functions in Economics Part-I.pdf
Dr. Subhash Unhale
 
PPTX
Volume of simple figues quiz
yusufteach
 
PDF
Coding
Prasanta Paul
 
PDF
Monad and Algebraic Design in Functional Programming
Namuk Park
 
TXT
Dvst
hahaa225
 
PDF
Chapter13 two-dimensional-array
Deepak Singh
 
PDF
Translating Linear Functions "I AM" Answer Key!
Deborah_Johnson
 
DOCX
Exp3
projectwork23
 
DOCX
Aval expres
Elisane Della Costa
 
PPTX
Python programing
BHAVYA DOSHI
 
PDF
Programa expresiones regulares
Anel Sosa
 
PDF
Clock For My
shamalanamnam
 
PDF
The simplest existential graph system
Armahedi Mahzar
 
TXT
Defining Function In Python
Mr.Usman Mani
 
PPTX
Mat lab lecture part 1
OmGulshan
 
PPTX
Quadratic functions
Ivy Estrella
 
Advanced
Logan Campbell
 
Scoda openrefine-directordata
Tony Hirst
 
Py lecture5 python plots
Yoshiki Satotani
 
Functions in Economics Part-I.pdf
Dr. Subhash Unhale
 
Volume of simple figues quiz
yusufteach
 
Monad and Algebraic Design in Functional Programming
Namuk Park
 
Dvst
hahaa225
 
Chapter13 two-dimensional-array
Deepak Singh
 
Translating Linear Functions "I AM" Answer Key!
Deborah_Johnson
 
Aval expres
Elisane Della Costa
 
Python programing
BHAVYA DOSHI
 
Programa expresiones regulares
Anel Sosa
 
Clock For My
shamalanamnam
 
The simplest existential graph system
Armahedi Mahzar
 
Defining Function In Python
Mr.Usman Mani
 
Mat lab lecture part 1
OmGulshan
 
Quadratic functions
Ivy Estrella
 

More from Alexey Bovanenko (20)

PDF
Python sqlite3
Alexey Bovanenko
 
PDF
python dict
Alexey Bovanenko
 
PDF
Python. Строки
Alexey Bovanenko
 
PDF
Python. Введение
Alexey Bovanenko
 
PPT
Nio java
Alexey Bovanenko
 
PPT
Конвертация строковых данных в числовые
Alexey Bovanenko
 
ODP
Assert c
Alexey Bovanenko
 
PPT
Обработка символов в языке C
Alexey Bovanenko
 
ODP
System c
Alexey Bovanenko
 
PPTX
Javascript functions
Alexey Bovanenko
 
PPTX
Javascript String object
Alexey Bovanenko
 
PDF
File. Java
Alexey Bovanenko
 
ODP
ZIP, GZIP Streams in java
Alexey Bovanenko
 
PDF
Конструктор копирования
Alexey Bovanenko
 
PDF
Tempale Intro
Alexey Bovanenko
 
PDF
transaction. php
Alexey Bovanenko
 
PDF
cookie. support by php
Alexey Bovanenko
 
PDF
php sessions
Alexey Bovanenko
 
ODP
Java IO. Streams
Alexey Bovanenko
 
ODP
Regular Expressions
Alexey Bovanenko
 
Python sqlite3
Alexey Bovanenko
 
python dict
Alexey Bovanenko
 
Python. Строки
Alexey Bovanenko
 
Python. Введение
Alexey Bovanenko
 
Конвертация строковых данных в числовые
Alexey Bovanenko
 
Обработка символов в языке C
Alexey Bovanenko
 
Javascript functions
Alexey Bovanenko
 
Javascript String object
Alexey Bovanenko
 
File. Java
Alexey Bovanenko
 
ZIP, GZIP Streams in java
Alexey Bovanenko
 
Конструктор копирования
Alexey Bovanenko
 
Tempale Intro
Alexey Bovanenko
 
transaction. php
Alexey Bovanenko
 
cookie. support by php
Alexey Bovanenko
 
php sessions
Alexey Bovanenko
 
Java IO. Streams
Alexey Bovanenko
 
Regular Expressions
Alexey Bovanenko
 
Ad

Recently uploaded (20)

PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PDF
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
PPTX
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PPTX
How to use _name_search() method in Odoo 18
Celine George
 
PPTX
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
PPTX
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
DOCX
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PPTX
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
PPTX
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
DOCX
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PPTX
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PPTX
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
Supply Chain Security A Comprehensive Approach 1st Edition Arthur G. Arway
rxgnika452
 
Martyrs of Ireland - who kept the faith of St. Patrick.pptx
Martin M Flynn
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
How to use _name_search() method in Odoo 18
Celine George
 
Project 4 PART 1 AI Assistant Vocational Education
barmanjit380
 
Iván Bornacelly - Presentation of the report - Empowering the workforce in th...
EduSkills OECD
 
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
ANNOTATION on objective 10 on pmes 2022-2025
joviejanesegundo1
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
A Case of Identity A Sociological Approach Fix.pptx
Ismail868386
 
How to use grouped() method in Odoo 18 - Odoo Slides
Celine George
 
MUSIC AND ARTS 5 DLL MATATAG LESSON EXEMPLAR QUARTER 1_Q1_W1.docx
DianaValiente5
 
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
ENGLISH -PPT- Week1 Quarter1 -day-1.pptx
garcialhavz
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
F-BLOCK ELEMENTS POWER POINT PRESENTATIONS
mprpgcwa2024
 
Ad

Python. re