I need to split a string where there\'s a comma, but it depends where the comma is placed.
As an example
consider the following:
C=75,user_is
If you don't have more than one level of parentheses, you could do a split on a comma that isn't followed by a closing ) before an opening (:
String[] splitArray = subjectString.split(
"(?x), # Verbose regex: Match a comma\n" +
"(?! # unless it's followed by...\n" +
" [^(]* # any number of characters except (\n" +
" \\) # and a )\n" +
") # end of lookahead assertion");
Your proposed rule would translate as
String[] splitArray = subjectString.split(
"(?x), # Verbose regex: Match a comma\n" +
"(?
but then you would miss a split in a text like
Org=NASA,Craft=Shuttle