I have a query that concatenates the values of two columns and returns a string as shown below:
423545(50),7568787(50),53654656,2021947(50),
Now i need to work on the individual numbers without the values in the brackets. I could rerun another query to retrieve the values but i am thinking it is more efficient to split the existing string instead of making another database call.
How can i split the above string to remove the values in brackets? I want to store the numbers in an ArrayList.
The arrayList will contain 423545,7568787,53654656,2021947, (without the commas)
Note that not all columns will have the bracketed value – See third column
There could be a comma at the end of the string.
I can split it using String.split() if it was just with commas but i guess the above format requires a regular expression.
See this demo.