Regular expressions are slow and often difficult to process. For your purpose, I would recommend built-in functional programming and list expressions:
In [115]: a = "asdf34fh2gh39qw3409sdgfklh"
In [116]: filter(lambda x: x.isdigit(), a)
Out[116]: '342393409'
In [117]: [char for char in filter(lambda x: x.isdigit(), a)]
Out[117]: ['3', '4', '2', '3', '9', '3', '4', '0', '9']
source
share