Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split String and Store in Array using Java

Tags:

java

arrays

split

I have a string that would always output in the following format, but with different lengths.

String s1= "['Aaaa', 'Eeee', 'Ffff', 'Cccc', 'Dddd']";

How to split this string and store the values in a n array of strings, I tried String.Split(), but I failed to catch the inner values.

Do you think regular expressions could help???

like image 240
user1899713 Avatar asked Jun 04 '26 19:06

user1899713


1 Answers

Have you tried running it through Split with the regex parameter as"[\\[\\]\\', ]"

Basically any of [,],,,', - more information here

like image 75
Karthik T Avatar answered Jun 06 '26 09:06

Karthik T



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!