Question: How can I remove the **whole word** `on` (**not the substring** `on` in the `Confirmed`) from the following string?

```
X-JP409 Confirmed on 13/2/12

```

Answer: 
There is special marker of word in regex: `\b`. So the better way is `myString.replaceAll("\\bon\\b", "");` 

This works when word 'on' is in the beginning, end and in the middle of the text but only if it is a separate word. For example it will not remove "on" from word "one".
```
"X-JP409 Confirmed on 13/2/12".replace(" on ", " ");

```

[String replace documentation](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace)