SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
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
?

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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
 

Similar 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
 

Similar 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

OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
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
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Anthony Dahanne
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profileakrivarotava
 

Último (20)

OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
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
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024Not a Kubernetes fan? The state of PaaS in 2024
Not a Kubernetes fan? The state of PaaS in 2024
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
SoftTeco - Software Development Company Profile
SoftTeco - Software Development Company ProfileSoftTeco - Software Development Company Profile
SoftTeco - Software Development Company Profile
 

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 ?