strip everything but digits from a string in python code example Example: python remove all except numbers >>> import re >>> re.sub('\D', '', 'aas30dsa20') '3020'