python - replace exact word while ignoring punctuation -
i know how replace exact word exception of ignoring punctuation
i've see answer nice fails on edges me.
here example replace:
"hi name john, , 30 yrs old."
to
"to hi name ted, , 30 yrs old."
thanks
>>> s = "hi name john, , 30 yrs old." >>> new_s = s.replace("john", "ted") >>> new_s 'hi name ted, , 30 yrs old.'
Comments
Post a Comment