public class Main { public static void main(String[] args) { String str = "[This is a] [Test String]"; System.out.println("String with square brackets: " + str); str = str.replaceAll("
",""); System.out.println("String after square brackets: " + str); } }
Output:
String with square brackets: [This is a] [Test String] String after square brackets: This is a Test String