The replaceAll method is attempting to match the String literal []
which does not exist within the String
try replacing these items separately.
String str = "[Chrissman-@1]";
str = str.replaceAll("\\[", "").replaceAll("\\]","");
More Related Contents:
- How to split a string if any chracter is found in java
- Split string to equal length substrings in Java
- Split string with dot as delimiter
- Splitting on comma outside quotes
- Java string split with “.” (dot) [duplicate]
- Splitting a string at every n-th character
- How to split String with some separator but without removing that separator in Java? [duplicate]
- Extracting pairs of words using String.split()
- Java String.split() Regex
- Split a string, at every nth position
- Java String.split() sometimes giving blank strings
- How to Split a mathematical expression on operators as delimiters, while keeping them in the result?
- Java split is eating my characters
- Split string into repeated characters
- Need some advice on split() method in Java [closed]
- Java: splitting a comma-separated string but ignoring commas in quotes
- Splitting a Java String by the pipe symbol using split(“|”)
- Why in Java 8 split sometimes removes empty strings at start of result array?
- How to convert comma-separated String to List?
- Java how to replace 2 or more spaces with single space in string and delete leading and trailing spaces
- How to split a comma-separated string?
- Get the index of a pattern in a string using regex
- Split regex to extract Strings of contiguous characters
- Understanding regex in Java: split(“\t”) vs split(“\\t”) – when do they both work, and when should they be used
- How to replace ” \ ” with ” \\ ” in java
- Validate a file name on Windows
- The split() method in Java does not work on a dot (.) [duplicate]
- Split string with | separator in java
- Regular Expressions on Punctuation
- Java’s Scanner vs String.split() vs StringTokenizer; which should I use?