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”
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']