This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Have you been through the String class, particularly what they call the parameters to the replaceAll method, and what they are described as? Have you been through the links given in the method description, and I trust you are familiar with what they mean? If not, read the Java Tutorials section.
And remember that | is a meta-character, but you might not have that problem if you use | in the right-hand parameter.
And remember that | is a meta-character, but you might not have that problem if you use | in the right-hand parameter. ...
Correct: the 2nd parameter is not a regex-aware String. But the $ followed by a number is used to interpolate a matched group from the first parameter (the regex aware String). So, only the '$' needs escaping in the 2nd parameter.