I am trying to replace one string with another one. The string that needs to be replaced can't end on a letter or number. I have the following regex at the moment :
myString.replaceAll("cloud[^a-z0-9A-Z]", "sun");
As expected, this regex will skip the word "clouds" but will replace the word "cloud#". In the 2nd case, both "cloud" and "#" will be replaced with "sun". How do I keep this # character so that the result of the regexp is sun# and not sun ?
myString.replaceAll("cloud[^a-z0-9A-Z]", "sun");
As expected, this regex will skip the word "clouds" but will replace the word "cloud#". In the 2nd case, both "cloud" and "#" will be replaced with "sun". How do I keep this # character so that the result of the regexp is sun# and not sun ?