How to match sequences of lowercase letters from a string with regular expression in Python

1 Answer

0 votes
import re     

s = 'xyx - aaXx .aaAyyy -aAaxYxxyYaaa.'    
pattern = '[a-z]+'  # sequences of lowercase letters

for match in re.findall(pattern, s):         
    print('Found: {!r}'.format(match))
    
    
'''
run:

Found: 'xyx'
Found: 'aa'
Found: 'x'
Found: 'aa'
Found: 'yyy'
Found: 'a'
Found: 'ax'
Found: 'xxy'
Found: 'aaa'

'''

 



answered Apr 27, 2019 by avibootz
...