Curso de Programación en Python/RegEx-15

De WikiCabal
Saltar a: navegación, buscar

re.findall()

[rrc@Pridd ~]$ python3
Python 3.4.3 (default, Jul  1 2015, 18:38:11) 
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> Str = "A fat cat doesn't eat oats but a rat eats bats."
>>> MatchedObject = re.findall( "[force]at", Str )
>>> print( MatchedObject )
['fat', 'cat', 'eat', 'oat', 'rat', 'eat']
>>> MatchedObject = re.findall( "at", Str )
>>> print( MatchedObject )
['at', 'at', 'at', 'at', 'at', 'at', 'at']
>>>