How to match sequences of non-digits from string with regular expression in Python

1 Answer

0 votes
import re     

s = 'xyx 234 aa44XY.aaAyyy984aABCaxYxx3yYaxaa.'    
pattern = r'\D+'  # sequence of non-digits

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

Found: 'xyx '
Found: ' aa'
Found: 'XY.aaAyyy'
Found: 'aABCaxYxx'
Found: 'yYaxaa.'

'''

 



answered Apr 27, 2019 by avibootz
...