How can I split a string in Java under specific conditions?

Viewed 25

I need to split a string in Java, comma by comma.

The problem is that there's "sub-commas" that I don't want to be splitted.

For example: the string is 12345, "september 7, 2022", lorem ipsum.

Normally, I'd use the split() method, but if I do so, "september 7 and 2022" would be two different indexes of the array of strings.

I apologize in advance for the question's title, I couldn't think of a better one.

0 Answers
Related