If you want to match specific knownWord do:
body = body.replaceAll("(?i)\\b"+knownWord + "\\b", replaceWord);
I think what you were looking for is the \\b
(word boundary) it is used to detect where words start/end, so commas or dots should no longer be a problem then.
More detailed example in response to your comment:
String body = "I'm going to school. ";
String knownWord = "school";
String replaceWord = "shop";
System.out.println(body.replaceAll("(?i)\\b"+knownWord + "\\b", replaceWord));
The above will print out the following:
I'm going to shop.