I want to replace only specific word in one string. However, some other words have that word inside but I don't want them to be changed.
For example, for the below string I only want to replace x with y in z string. how to do that?
x = "112-224"
y = "hello"
z = "This is the number 112-224 not #112-224"
When I do re.sub(r'\b' + x + r'\b', y, z)
I am getting 'This is the number hello not #hello'
. So basically doesn't work with this regex. I am really not good with this regex stuff. What's the right way to do that? so, i can get This is the number hello not #112-224
.