-1

I have the following array:

[["12","21","31","41"],["empty","22","32","42"],["13","23","33","43"]]

After my regex of:

picset.replaceAll("\\[\\[\"|\"\\]\\]|", "");

Output:

"12","21","31","41"],["empty","22","32","42"],["13","23","33","43"

How do I remove the remaining brackets? I should also note I am looping through several arrays with different sizes its not just this specific array.

RianSki
  • 1
  • 4
  • 1
    Use `picset.replaceAll("\\[|\\]", "");` – Jose Da Silva Gomes Mar 18 '18 at 19:35
  • 1
    `.replaceAll("[\\]\\[]+", "")` – Wiktor Stribiżew Mar 18 '18 at 19:37
  • You say you have an Array? but you are treating it like a string. So, which is it? Do you have an Array or a String?? – Barns Mar 18 '18 at 20:13
  • @Barns it's an array of strings, Though I don't see how that matters with my problem. The comments have solved my issue so thanks to those people. – RianSki Mar 18 '18 at 21:47
  • It 'matters' because I do not see the purpose in changing an array of strings into a `String` then using `relpaceAll()` just to get another `String` representation of a collection of numbers. You have not said what you intended to do with the new `String` once you get it, but somehow I doubt that you are finished with the result as it is. Besides that (no offense to Istvan) but the accepted solution is far from optimal. – Barns Mar 19 '18 at 15:31
  • @Barns i'm using it to add each string to the end of a URL to retrieve images though I doubt that helps your understanding. All the comments solved my issue and it's working as intended. – RianSki Mar 19 '18 at 19:31

1 Answers1

0

If I take the logic you are forcing try adding another line of code.

picset.replaceAll("\\[\\[\"|\"\\]\\]|", "");
picset.replaceAll("\"\\],\\[\"", "\",\"");
Istvan
  • 613
  • 5
  • 5