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".
What about:

```
String str = "X-JP409 Confirmed on 13/2/12";
str.replaceAll(" on ", " ");

```

The output is what you are looking for:

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

```