When you use replaceAll in Java, you cannot use a "$" or a "\" in the replacement String.

It throws a java.lang.IndexOutOfBoundsException: No group XX exception. The solution is here. The "$" and the "\" in the replacement string have to be delimited before being sent in to the Regex parser.