Q:

Java - replace all

I am getting all the user ids and I need to remove some characters.  I am adding them to an arraylist in a loop, but they are being added in this format:
"[a1234567]"
"[b1234567]"

I want to remove any " or [ or ] so it just leaves e.g. a1234567
I tried this:
userNumbers.add(link.getUserId().replaceAll("[\"\\[\\]]","") );

But nothing seemed to happen?

A:

String userNumber = "\"[b1234567]\"";
System.out.println(userNumber.replaceAll("[\"\\[\\]]",""));

Output: b1234567
Why do you think that nothing seem to happen?
Update:

Comment: Would performing a .toString() on an ArrayList cause this?

Source code ArrayList.toString() (inherited from AbstractCollection):
public String toString() {
    Iterator<E> it = iterator();
    if (! it.hasNext())
        return "[]";

    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (;;) {
        E e = it.next();
        sb.append(e == this ? "(this Collection)" : e);
        if (! it.hasNext())
            return sb.append(']').toString();
        sb.append(',').append(' ');
    }
}

You should loop the collection and print every single String or append them to one String if you don't want them like this ["b1234567"].

A:

Use the following: 
userNumbers.add(link.getUserId().replaceAll(.replaceAll("\"\\[|\\]\"", ""));

Got it here : https://stackoverflow.com/a/15083671/3714122

