def hide_reserve_3(s):
return '*' * (len(s[0])-3) + s[0][-3:]
re.sub(r'\d+', hide_reserve_3, 'User\'s mobile number is 1234567890')
output: "User's mobile number is *******890"
Above I've retrieved from
https://medium.com/towards-data-science/7-useful-tricks-for-python-regex-you-should-know-ec20381e22f2
I just don't quite get why there is a slicing operation in the function. (s[0])
Can someone please explain it to me thoroughly what is going on?
Thanks.