Summary. Use the replace() method to return a new string with a substring replaced by a new one . Use a regular expression with the global flag ( g ) to replace all occurrences of a substring with a new one.
Read moreHow do you replace all strings in a string in Java?
String str = “[Chrissman-@1]”; str = replaceAll(“\\[\\]”, “”); String[] temp = str. split(“-@”); System. out. println(“Nickname: ” + temp[0] + ” | Power: ” + temp[1]);
Read more