I have a string that will have digits in that, we need to remove all the characters which are not digits and replace the digits with #
I have written a regex, its able to replace the digits with #, but I could not find the regex to remove the characters which are not digits.
import re
def replace_digits(string):
m=re.sub("\d","#",string)
Examples :
234
-> ###
a2b3c4
-> ###
abc
-> <empty string>
#2a$#b%c%561#
-> ####