SlideShare uma empresa Scribd logo
1 de 22
Baixar para ler offline
dura regex sed regex
por wairton de abreu
2
3
Stephen Cole Kleene
(1909 - 1994)
o que é uma expressão regular?
4
import re
['DEBUG', 'DOTALL', 'I', 'IGNORECASE', 'L', 'LOCALE', 'M',
'MULTILINE', 'S', 'Scanner', 'T', 'TEMPLATE', 'U', 'UNICODE',
'VERBOSE', 'X', '_MAXCACHE', '__all__', '__builtins__', '__doc__',
'__file__', '__name__', '__package__', '__version__', '_alphanum',
'_cache', '_cache_repl', '_compile', '_compile_repl', '_expand',
'_pattern_type', '_pickle', '_subx', 'compile', 'copy_reg', 'error',
'escape', 'findall', 'finditer', 'match', 'purge', 'search', 'split',
'sre_compile', 'sre_parse', 'sub', 'subn', 'sys', 'template']
5
import re
['A', '_alphanum_str', 'ASCII', 'fullmatch', '__loader__', 'copyreg',
'__cached__', '_alphanum_bytes', '__spec__']
6
o básico (parte 1) ? * + . 
“pessoas?” “faz(em)?”
“go+l” “gol” “goooooooooool”-> ou
7
.match() e .search()
match(pattern, string, flags=0)
Try to apply the pattern at the start of the string, returning
a match object, or None if no match was found.
search(pattern, string, flags=0)
Scan through string looking for a match to the pattern, returning
a match object, or None if no match was found.
8
Pattern → compile → Match
>>> pattern = re.compile("andr[eé](ia)?")
>>> match = pattern.match("andreia")
>>> match.group()
'andreia'
9
d, D, w, W, s e S
[a-zA-Z0-9_] [^a-zA-Z0-9_]
[ tn] [^ tn]
[a-zA-Z0-9_] [^a-zA-Z0-9_]
[0-9] [^0-9]
10
a barra e o r
section → section → section → r“section”
11
o básico (parte 2) | [ ] ( ) { } ^ $
12
(?i) (?s)
case insensitive
o . captura quebra de linha
13
b B
"eu sou um pythonista! Sim, python é melhor do que ..."
14
.finditer() e .findall()
findall(pattern, string, flags=0)
Return a list of all non-overlapping matches in the string.
(...)
finditer(pattern, string, flags=0)
Return an iterator over all non-overlapping matches in the
string. For each match, the iterator returns a match object.
15
.split(), .sub() e .subn()
sub(pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl...
16
a classe Match
['end', 'endpos', 'expand', 'group', 'groupdict', 'groups',
'lastgroup', 'lastindex', 'pos', 're', 'regs', 'span', 'start', 'string']
17
e o unicode?
>>> re.search("κα "," γώ ε μι δ ς κα λήθεια κα ζωή")ὶ Ἐ ἰ ἡ ὁ ὸ ὶ ἡ ἀ ὶ ἡ
<_sre.SRE_Match object; span=(16, 19), match='κα '>ὶ
18
grupos
>>> p = re.compile('(a(b)c)d')
>>> m = p.match('abcd')
>>> m.group(0)
'abcd'
>>> m.group(1)
'abc'
>>> m.group(2)
'b'
19
grupos nomeados
from django.conf.urls import url
urlpatterns = [
url(r'^articles/2003/$', 'news.views.special_case_2003'),
url(r'^articles/(?P<year>[0-9]{4})/$', 'news.views.year_archive'),
url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$',
'news.views.month_archive'),
]
20
o que faltou?
quantificadores possessivos
lookahead e lookbehind
backreference
21
para onde agora?
expressões regulares – uma abordagem divertida
expressões regulares cookbook
https://docs.python.org/3/howto/regex.html#regex-howto
https://docs.python.org/3/library/re.html
http://www.regular-expressions.info
22
?

Mais conteúdo relacionado

Mais procurados

20190330 immutable data
20190330 immutable data20190330 immutable data
20190330 immutable dataChiwon Song
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)GroovyPuzzlers
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlSway Wang
 
Class 7a: Functions
Class 7a: FunctionsClass 7a: Functions
Class 7a: FunctionsMarc Gouw
 
CS50 Lecture3
CS50 Lecture3CS50 Lecture3
CS50 Lecture3昀 李
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorerithion
 
Arrow 101 - Kotlin funcional com Arrow
Arrow 101 - Kotlin funcional com ArrowArrow 101 - Kotlin funcional com Arrow
Arrow 101 - Kotlin funcional com ArrowLeandro Ferreira
 
Functional Pattern Matching on Python
Functional Pattern Matching on PythonFunctional Pattern Matching on Python
Functional Pattern Matching on PythonDaker Fernandes
 
The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6Bryan Hughes
 
R で解く FizzBuzz 問題
R で解く FizzBuzz 問題R で解く FizzBuzz 問題
R で解く FizzBuzz 問題Kosei ABE
 
Introduction functionalprogrammingjavascript
Introduction functionalprogrammingjavascriptIntroduction functionalprogrammingjavascript
Introduction functionalprogrammingjavascriptCarolina Pascale Campos
 
HailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDBHailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDBstewartsmith
 
React Js Training In Bangalore | ES6 Concepts in Depth
React Js Training   In Bangalore | ES6  Concepts in DepthReact Js Training   In Bangalore | ES6  Concepts in Depth
React Js Training In Bangalore | ES6 Concepts in DepthSiva Vadlamudi
 

Mais procurados (20)

20190330 immutable data
20190330 immutable data20190330 immutable data
20190330 immutable data
 
The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)The groovy puzzlers (as Presented at JavaOne 2014)
The groovy puzzlers (as Presented at JavaOne 2014)
 
Groovy
GroovyGroovy
Groovy
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Class 7a: Functions
Class 7a: FunctionsClass 7a: Functions
Class 7a: Functions
 
CS50 Lecture3
CS50 Lecture3CS50 Lecture3
CS50 Lecture3
 
The most exciting features of PHP 7.1
The most exciting features of PHP 7.1The most exciting features of PHP 7.1
The most exciting features of PHP 7.1
 
dplyr
dplyrdplyr
dplyr
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
 
Namespaces
NamespacesNamespaces
Namespaces
 
Slides
SlidesSlides
Slides
 
Arrow 101 - Kotlin funcional com Arrow
Arrow 101 - Kotlin funcional com ArrowArrow 101 - Kotlin funcional com Arrow
Arrow 101 - Kotlin funcional com Arrow
 
Functional Pattern Matching on Python
Functional Pattern Matching on PythonFunctional Pattern Matching on Python
Functional Pattern Matching on Python
 
Vcs23
Vcs23Vcs23
Vcs23
 
The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6The Lesser Known Features of ECMAScript 6
The Lesser Known Features of ECMAScript 6
 
c programming
c programmingc programming
c programming
 
R で解く FizzBuzz 問題
R で解く FizzBuzz 問題R で解く FizzBuzz 問題
R で解く FizzBuzz 問題
 
Introduction functionalprogrammingjavascript
Introduction functionalprogrammingjavascriptIntroduction functionalprogrammingjavascript
Introduction functionalprogrammingjavascript
 
HailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDBHailDB: A NoSQL API Direct to InnoDB
HailDB: A NoSQL API Direct to InnoDB
 
React Js Training In Bangalore | ES6 Concepts in Depth
React Js Training   In Bangalore | ES6  Concepts in DepthReact Js Training   In Bangalore | ES6  Concepts in Depth
React Js Training In Bangalore | ES6 Concepts in Depth
 

Destaque

Study abroad photo essay
Study abroad photo essayStudy abroad photo essay
Study abroad photo essayjohannazeller10
 
Presentation 6
Presentation 6Presentation 6
Presentation 6TELICIA
 
CS Education Event - The Project Factory
CS Education Event - The Project FactoryCS Education Event - The Project Factory
CS Education Event - The Project FactoryCollaborative Solutions
 
Voice Thread
Voice ThreadVoice Thread
Voice Threadadarr12
 
Collaborative Solutions eHealth Event - CSC Australia
Collaborative Solutions eHealth Event - CSC AustraliaCollaborative Solutions eHealth Event - CSC Australia
Collaborative Solutions eHealth Event - CSC AustraliaCollaborative Solutions
 
Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...
Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...
Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...Collaborative Solutions
 
Outage Management System - Report
Outage Management System - ReportOutage Management System - Report
Outage Management System - Reportflagshipcenter
 
Многоканальная электронная коммерция
Многоканальная электронная коммерцияМногоканальная электронная коммерция
Многоканальная электронная коммерцияceteralabs
 
Cetera презентация компании
Cetera презентация компанииCetera презентация компании
Cetera презентация компанииceteralabs
 
コンピュータの歴史
コンピュータの歴史コンピュータの歴史
コンピュータの歴史Daichi Nakajima
 

Destaque (17)

Vagrant, já resolvi
Vagrant, já resolviVagrant, já resolvi
Vagrant, já resolvi
 
Study abroad photo essay
Study abroad photo essayStudy abroad photo essay
Study abroad photo essay
 
Caricatura
CaricaturaCaricatura
Caricatura
 
Presentation 6
Presentation 6Presentation 6
Presentation 6
 
CS Education Event - The Project Factory
CS Education Event - The Project FactoryCS Education Event - The Project Factory
CS Education Event - The Project Factory
 
CS Education Event - MeTag
CS Education Event - MeTagCS Education Event - MeTag
CS Education Event - MeTag
 
CS Education Event - Microsoft
CS Education Event - MicrosoftCS Education Event - Microsoft
CS Education Event - Microsoft
 
Voice Thread
Voice ThreadVoice Thread
Voice Thread
 
American Eagle Pitch
American Eagle PitchAmerican Eagle Pitch
American Eagle Pitch
 
Google Penguin 2.0 Update
Google Penguin 2.0 UpdateGoogle Penguin 2.0 Update
Google Penguin 2.0 Update
 
Collaborative Solutions eHealth Event - CSC Australia
Collaborative Solutions eHealth Event - CSC AustraliaCollaborative Solutions eHealth Event - CSC Australia
Collaborative Solutions eHealth Event - CSC Australia
 
Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...
Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...
Collaborative Solutions eHealth Event -- University of Newcastle - Nutrition ...
 
Outage Management System - Report
Outage Management System - ReportOutage Management System - Report
Outage Management System - Report
 
Многоканальная электронная коммерция
Многоканальная электронная коммерцияМногоканальная электронная коммерция
Многоканальная электронная коммерция
 
Cetera презентация компании
Cetera презентация компанииCetera презентация компании
Cetera презентация компании
 
コンピュータの歴史
コンピュータの歴史コンピュータの歴史
コンピュータの歴史
 
De digitale uitdaging in het onderwijs
De digitale uitdaging in het onderwijsDe digitale uitdaging in het onderwijs
De digitale uitdaging in het onderwijs
 

Semelhante a Duralexsedregex

Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python TricksBryan Helmig
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Troy Miles
 
Core csharp and net quick reference
Core csharp and net quick referenceCore csharp and net quick reference
Core csharp and net quick referenceilesh raval
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick referenceArduino Aficionado
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎juzihua1102
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎anzhong70
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)gekiaruj
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayUtkarsh Sengar
 
Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of RubyTom Crinson
 
Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutesSidharth Nadhan
 
gptips1.0concrete.matConcrete_Data[1030x9 double array]tr.docx
gptips1.0concrete.matConcrete_Data[1030x9  double array]tr.docxgptips1.0concrete.matConcrete_Data[1030x9  double array]tr.docx
gptips1.0concrete.matConcrete_Data[1030x9 double array]tr.docxwhittemorelucilla
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocationNaveen Gupta
 

Semelhante a Duralexsedregex (20)

Python Basic
Python BasicPython Basic
Python Basic
 
Stupid Awesome Python Tricks
Stupid Awesome Python TricksStupid Awesome Python Tricks
Stupid Awesome Python Tricks
 
Lập trình Python cơ bản
Lập trình Python cơ bảnLập trình Python cơ bản
Lập trình Python cơ bản
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Core csharp and net quick reference
Core csharp and net quick referenceCore csharp and net quick reference
Core csharp and net quick reference
 
Core c sharp and .net quick reference
Core c sharp and .net quick referenceCore c sharp and .net quick reference
Core c sharp and .net quick reference
 
Python Cheat Sheet
Python Cheat SheetPython Cheat Sheet
Python Cheat Sheet
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
第二讲 Python基礎
第二讲 Python基礎第二讲 Python基礎
第二讲 Python基礎
 
第二讲 预备-Python基礎
第二讲 预备-Python基礎第二讲 预备-Python基礎
第二讲 预备-Python基礎
 
Python 2.5 reference card (2009)
Python 2.5 reference card (2009)Python 2.5 reference card (2009)
Python 2.5 reference card (2009)
 
Python Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard WayPython Workshop - Learn Python the Hard Way
Python Workshop - Learn Python the Hard Way
 
Intro to ruby
Intro to rubyIntro to ruby
Intro to ruby
 
Hidden treasures of Ruby
Hidden treasures of RubyHidden treasures of Ruby
Hidden treasures of Ruby
 
Learn python in 20 minutes
Learn python in 20 minutesLearn python in 20 minutes
Learn python in 20 minutes
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
gptips1.0concrete.matConcrete_Data[1030x9 double array]tr.docx
gptips1.0concrete.matConcrete_Data[1030x9  double array]tr.docxgptips1.0concrete.matConcrete_Data[1030x9  double array]tr.docx
gptips1.0concrete.matConcrete_Data[1030x9 double array]tr.docx
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Python basic
Python basicPython basic
Python basic
 

Último

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 

Último (20)

SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 

Duralexsedregex

  • 1. dura regex sed regex por wairton de abreu
  • 2. 2
  • 3. 3 Stephen Cole Kleene (1909 - 1994) o que é uma expressão regular?
  • 4. 4 import re ['DEBUG', 'DOTALL', 'I', 'IGNORECASE', 'L', 'LOCALE', 'M', 'MULTILINE', 'S', 'Scanner', 'T', 'TEMPLATE', 'U', 'UNICODE', 'VERBOSE', 'X', '_MAXCACHE', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__version__', '_alphanum', '_cache', '_cache_repl', '_compile', '_compile_repl', '_expand', '_pattern_type', '_pickle', '_subx', 'compile', 'copy_reg', 'error', 'escape', 'findall', 'finditer', 'match', 'purge', 'search', 'split', 'sre_compile', 'sre_parse', 'sub', 'subn', 'sys', 'template']
  • 5. 5 import re ['A', '_alphanum_str', 'ASCII', 'fullmatch', '__loader__', 'copyreg', '__cached__', '_alphanum_bytes', '__spec__']
  • 6. 6 o básico (parte 1) ? * + . “pessoas?” “faz(em)?” “go+l” “gol” “goooooooooool”-> ou
  • 7. 7 .match() e .search() match(pattern, string, flags=0) Try to apply the pattern at the start of the string, returning a match object, or None if no match was found. search(pattern, string, flags=0) Scan through string looking for a match to the pattern, returning a match object, or None if no match was found.
  • 8. 8 Pattern → compile → Match >>> pattern = re.compile("andr[eé](ia)?") >>> match = pattern.match("andreia") >>> match.group() 'andreia'
  • 9. 9 d, D, w, W, s e S [a-zA-Z0-9_] [^a-zA-Z0-9_] [ tn] [^ tn] [a-zA-Z0-9_] [^a-zA-Z0-9_] [0-9] [^0-9]
  • 10. 10 a barra e o r section → section → section → r“section”
  • 11. 11 o básico (parte 2) | [ ] ( ) { } ^ $
  • 12. 12 (?i) (?s) case insensitive o . captura quebra de linha
  • 13. 13 b B "eu sou um pythonista! Sim, python é melhor do que ..."
  • 14. 14 .finditer() e .findall() findall(pattern, string, flags=0) Return a list of all non-overlapping matches in the string. (...) finditer(pattern, string, flags=0) Return an iterator over all non-overlapping matches in the string. For each match, the iterator returns a match object.
  • 15. 15 .split(), .sub() e .subn() sub(pattern, repl, string, count=0, flags=0) Return the string obtained by replacing the leftmost non-overlapping occurrences of the pattern in string by the replacement repl...
  • 16. 16 a classe Match ['end', 'endpos', 'expand', 'group', 'groupdict', 'groups', 'lastgroup', 'lastindex', 'pos', 're', 'regs', 'span', 'start', 'string']
  • 17. 17 e o unicode? >>> re.search("κα "," γώ ε μι δ ς κα λήθεια κα ζωή")ὶ Ἐ ἰ ἡ ὁ ὸ ὶ ἡ ἀ ὶ ἡ <_sre.SRE_Match object; span=(16, 19), match='κα '>ὶ
  • 18. 18 grupos >>> p = re.compile('(a(b)c)d') >>> m = p.match('abcd') >>> m.group(0) 'abcd' >>> m.group(1) 'abc' >>> m.group(2) 'b'
  • 19. 19 grupos nomeados from django.conf.urls import url urlpatterns = [ url(r'^articles/2003/$', 'news.views.special_case_2003'), url(r'^articles/(?P<year>[0-9]{4})/$', 'news.views.year_archive'), url(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', 'news.views.month_archive'), ]
  • 20. 20 o que faltou? quantificadores possessivos lookahead e lookbehind backreference
  • 21. 21 para onde agora? expressões regulares – uma abordagem divertida expressões regulares cookbook https://docs.python.org/3/howto/regex.html#regex-howto https://docs.python.org/3/library/re.html http://www.regular-expressions.info
  • 22. 22 ?