I need a way to replace words in sentences so for example, "hi, something". I need to replace it with "hello, something"
.
str.replaceAll("hi", "hello")
gives me "hello, somethellong"
.
I've also tried str.replaceAll(".*\\W.*" + "hi" + ".*\\W.*", "hello")
, which I saw on another solution on here however that doesn't seem to work either.
What's the best way to achieve this so I only replace words not surrounded by other alphanumeric characters?