SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
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
?

Contenu connexe

Tendances

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
 

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

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
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
 
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
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
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
 
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
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
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
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
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
 
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
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
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
 

Dernier (20)

Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
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
 
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...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
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
 
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...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
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...
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
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
 
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
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
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
 

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 ?