Made apt changes to pandas.Series.str.replace()
- [x] closes #31225 
- [ ] tests added / passed
- [ ] passes `black pandas`
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`


Thanks @ashwinpn 