I want to convert only numbers in this str
"ABC234TSY65234525erQ"
I tried to change only areas with numbers to the * sign
This is what I wanted
"ABC*TSY*erQ"
But when I actually did it, it came out like this
"ABC***TSY********erQ"
How do I change it?
Thanks you!
>Solution :
use \d+. + in a regular expression means "match the preceding character one or more times"
import re
s = re.sub(r'\d+', '*', s)
output:
'ABC*TSY*erQ'