You did not assign it to test. Strings are immutable.
test = test.replace("KP", "");
You need to assign it back to test.
You did not assign it to test. Strings are immutable.
test = test.replace("KP", "");
You need to assign it back to test.