How would I remove all square brackets ("[]") from a given String in Java?
String s = "[abcdefg]"; s = s.replaceAll(regex, "");
What regular expression would be used in this case?
Use this one:
String s = "[abcdefg]"; String regex = "\[|\]"; s = s.replaceAll(regex, ""); System.out.println(s);
2.1m questions
2.1m answers
60 comments
57.0k users