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 -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -