How to remove alphabets from an alphanumeric string in Python

1 Answer

0 votes
import re
 
s = 'python 17 d 900 e 8542'
 
pattern = r'[^0-9 ]+'
 
s = re.sub(pattern, '', s)
 
print(s)
 
 
 
 
'''
run:
 
 17  900  8542

'''

 



answered Nov 10, 2022 by avibootz

Related questions

1 answer 111 views
1 answer 121 views
1 answer 100 views
1 answer 119 views
1 answer 105 views
...