I am learning java and I want to replace all [] and {}
with a space using java
RegExp
.
What i'm tried,
final String data = "{a:b,c:d,e:[f,g,h]}";
System.out.println(data.replaceAll("[{}[]]", " "));
but am getting java.util.regex.PatternSyntaxException: Unclosed character class near index 5 [{}[]].
^
I think the java thinks that the ]
at 5th position as the ending point of the RegExp
.
So how can i escape that square bracket and replace all []{}
with a space .