-1

I made this code:

import re

match = re.search(r'[DER]\d+[Y]', 'DER1234Y' )  
print(match.group())

and it prints this :

R1234Y

I want the code to only print the numbers and nothing else. How to do that ?

1 Answers1

-1

It's basically regex. So would this work?: re.sub('[^0-9]+', '', 'DER1234Y')

[^0-9]+ = everything that is not a numeric value (0-9).

C K
  • 16
  • 3