I have a string as follows: entries(a,b,c,d,e)
I would like to split the following into an array in java as
arr[0]= 'a'
arr[1]= 'b'
arr[2]= 'c'
arr[3]= 'd'
arr[4]= 'e'
Anyone have any idea on the regex to do this?
I have a string as follows: entries(a,b,c,d,e)
I would like to split the following into an array in java as
arr[0]= 'a'
arr[1]= 'b'
arr[2]= 'c'
arr[3]= 'd'
arr[4]= 'e'
Anyone have any idea on the regex to do this?
String[] arr = "entries(a,b,c,d,e)".split("\\(|\\)")[1].split(",");
Explanation: You have the string "entries(a,b,c,d,e)" and first want to get to the "a,b,c,d,e" part. I use split here and define that I want to split by "(" or ")". Gives me the array
a[0] = "entries"
a[1] = "a,b,c,d,e"
Take the second entry and split it by ",", hence [1].split(",")
at the end.