How to match sequences of one uppercase followed by lowercase letters from string with regular expression in Python

1 Answer

0 votes
import re     

s = 'xyx - aaXY.aaAyyy-aABCaxYxxyYaaa.'    
pattern = '[A-Z][a-z]+'  # sequences of one uppercase followed by lowercase

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

Found: 'Ayyy'
Found: 'Cax'
Found: 'Yxxy'
Found: 'Yaaa'

'''

 



answered Apr 27, 2019 by avibootz
...