Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Expressões Regulares para novatos, usando Python
Search
Amom Mendes
July 09, 2016
Programming
22
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Expressões Regulares para novatos, usando Python
Amom Mendes
July 09, 2016
Other Decks in Programming
See All in Programming
contenteditable と日本語入力に向き合う
colorful12
0
200
気持ちぃ〜角丸 Squircle
ryu1013
0
310
Agents on Rails - Rails at Scale 2026
irinanazarova
0
560
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
220
Jetpack Compose Mechanisms
skydoves
3
820
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
32k
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
270
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
290
golang-bob.pdf
iwatsukayura
0
130
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
55
13k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
480
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
A Modern Web Designer's Workflow
chriscoyier
699
190k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Writing Fast Ruby
sferik
630
63k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Transcript
Globalcode – Open4education Expressões Regulares para novatos, usando Python Amom
Mendes
Globalcode – Open4education Agenda • O que são expressões regulares
• Para que servem? • Metacaracteres • Notebook
Globalcode – Open4education Agenda • O que são expressões regulares
• Para que servem? • Metacaracteres • Notebook
Globalcode – Open4education Agenda • O que são expressões regulares
• Para que servem? • Metacaracteres • Notebook
Globalcode – Open4education Agenda • O que são expressões regulares
• Para que servem? • Metacaracteres • Notebook (talvez!)
Globalcode – Open4education Motivação
Globalcode – Open4education Motivação
Globalcode – Open4education O que são Expressões regulares?
Globalcode – Open4education O que são Expressões regulares? “Método formal
de especificar um padrão de texto” import re
Globalcode – Open4education O que são Expressões regulares? “Hoje tem
trilha de Python no TDC” Caracteres literais
Globalcode – Open4education O que são Expressões regulares? “Hoje tem
trilha de Python no TDC” re.search (r‘(?i) (python).*(tdc)) Caracteres literais Regra(Símb. + Carac. Fn. Especiais)
Globalcode – Open4education O que são Expressões regulares? “Hoje tem
trilha de Python no TDC” re.search (r‘(?i) (python).*(tdc)) ‘Python no tdc’ Caracteres literais Regra(Símb. + Carac. Fn. Especiais) Match (casou)
Globalcode – Open4education Para que servem? • Muita | Qualquer
coisa relacionada a busca de padrões de caracteres • Router de páginas (ex. django) • Datas / Horários • Nomes • E-mails • Web Scrapping • Consulta bancos de dados • Substituição de caracteres • Etc, etc
Globalcode – Open4education Por onde começar?
Globalcode – Open4education Metacaracteres • Principais . ? * +
^ $ | [ ] { } ( ) \
Globalcode – Open4education Metacaracteres • Simplificando ^$\b Representantes Quantificadores Âncoras
Outros . [ ][^] ?*+{ } \ | (..) \1
Globalcode – Open4education Metacaracteres . Método findall: retorna um lista
com textos casados ( ) • Representantes
Globalcode – Open4education Metacaracteres . re.findall(r'n.o', #Expressão 'não, nao, neo,
nso, nzo,nap')#String ['não', 'nao', 'neo', 'nso', 'nzo'] • Representantes
Globalcode – Open4education Metacaracteres [...] • Representantes
Globalcode – Open4education Metacaracteres re.findall (r'[naão]', 'não, nao, neo') ['n',
'ã', 'o', 'n', 'a', 'o', 'n', 'o'] • Representantes
Globalcode – Open4education Metacaracteres m = re.search(r'[0-9][0-9]:[0-9][0-9]', 'Cheguei as 11:00
horas no TDC hoje') m.group() • Representantes
Globalcode – Open4education Metacaracteres m = re.search(r'[0-9][0-9]:[0-9][0-9]', 'Cheguei as 11:00
horas no TDC hoje') m.group() Método search: testa se casou e retorna um objeto com informações do match ( ) • Representantes
Globalcode – Open4education Metacaracteres m = re.search(r'[0-9][0-9]:[0-9][0-9]', 'Cheguei as 11:00
horas no TDC hoje') m.group() 11:00 • Representantes
Globalcode – Open4education m = re.findall(r'[^A-z ]’, 'Cheguei as 11:
00 horas no TDC hoje') ['1', '1', ':', '0', '0'] Metacaracteres • Representantes
Globalcode – Open4education ? Metacaracteres • Quantificadores
Globalcode – Open4education re.findall (r'fala[r!]?', 'falar, fala!, fala') ['falar', 'fala!',
'fala'] Metacaracteres • Quantificadores
Globalcode – Open4education * Metacaracteres • Quantificadores
Globalcode – Open4education re.findall (r'Ah*!', 'Ah!, Ahhh!, Ahhhh!, Ahhhhhhhhh!') ['Ah!',
'Ahhh!', 'Ahhhh!', 'Ahhhhhhhhh!'] Metacaracteres • Quantificadores
Globalcode – Open4education .* re.findall (r'Ah.*!', 'Ah!, Ahhh!, Ahhhh!,A(h *
1000)!') 'Ah!, Ahhh!, Ahhhh!,A (h * 1000)!' Metacaracteres • Quantificadores
Globalcode – Open4education + if re.search(r'Ah+!', 'A!'): print (‘Casou’) else:
print (‘Não Casou’) Não Casou Metacaracteres • Quantificadores
Globalcode – Open4education { } Metacaracteres • Quantificadores
Globalcode – Open4education re.findall (r'Ah{1,3}!','Ah!, Ahhh!, Ahhhh!, Ahhhhhhhhh!') ['Ah!', 'Ahhh!']
Metacaracteres • Quantificadores
Globalcode – Open4education Metacaracteres • Ancoras
Globalcode – Open4education = fome! Metacaracteres • Ancoras
Globalcode – Open4education notebook
Globalcode – Open4education Obrigado!
[email protected]