And i have no idea why!
I bascially have a STRING (yes, not an array), that has the following contents:
[something, something else, somoething, trallala, something]
And i want to turn it into a String[]. So first off i substring() off the first and the last character to get rid of the brackets []. Then i use the split() function to split by comma. I tried using both “\|” and “,” and “\,” with the same results.
This is what i get:
[Ljava.lang.String;@186d4c1
Here’s the code for it. I made it into a one-liner:
String[] urlArr = ((matcher.group(3).toString()).substring(1, (matcher.group(3).length()-1))).split(",");
As you can see the first part is (matcher.group(3).toString()), and it DOES return a valid string (like the example i posted above). So i don’t get why it’s not working.
Any ideas?
EDIT:
I clarified the code a bit:
String arrString = matcher.group(3).toString();
int length = arrString.length();
String[] urlArr = (arrString.substring(1, length-1)).split(",");
System.out.println(urlArr);
You are getting a valid array of
Strings, but trying to print it directly does not do what you would expect it to do. Try e.g.Update
If you want to process the parsed tokens one by one, you can simply iterate through the array, e.g.