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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

spring cloud - How to configure SpringCloud Eureka instance to point to https on non standard port -

javascript - Bootstrap Popover: iOS Safari strange behaviour -