In a programm like this:

```
String userInput = "[]";
String str = "Hello World[]!";
String replacement = "";
str = str.replaceAll(userInput, replacement);
System.out.print(str);

```

I get the error:

```
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed character class near index 1
[]

```

But I want the ouput:

```
Hello World!

```

Is there are way to make userInput safe for replaceAll? Let's say the userInput is: `[]`. How do I need to process the String to always replace the String an not the meaning of the String.