This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
You say in your question that you want to chage test's to test\'s, but your code is trying to change it to test'/s
Assuming you wanted what you said in the question, you need to escape the '\', because '\' is a special character in Java Strings. Try
@Ronda - this will work because test is a String reference, so the second line actually just points it at the new String and the original String is no longer referenced and so is available for garbage collection.