0

I know that are plenty of regular expressions around here similar to what I am going to ask, but couldn't find one that actually helps me. This one got close, but it uses Java split method, but I need to capture the values using only regular expressions: Java: splitting a comma-separated string but ignoring commas in quotes

So, what I need to do is, given the below input:
string,string([a-zA-Z]{0,9}),integer
I would like to capture 3 matches:
string
string([a-zA-Z]{0,9})
integer

Note that inside the parenthesis we can have a regular expression, which means almost any chars, even comma.
I can't use split here, because I am not using Java, but an internal declarative programming that uses ICU regular expressions and has an API for capturing groups, but not a regex based split method.
Any help would be appreciated. And I am really sorry if there exists other posts that could be duplicated as this one, but I have spent a few hours looking around, and even played with the post I mentioned, but couldn't get to a solution.
Thanks

EDIT
The input I provided is just an example, but other inputs are also possible.
Besides, after @sin comments, I have reviewed the input, and we can actually assume we'll have quotes inside the parenthesis, like that:
string("[\w]{0,9}"),integer,string

  • So since the tool you're using doesn't have a split method, you're looking for a regex that has the 3 matches `string`, `string([a-zA-Z]{0,9})`, and `integer`? Or would a regex that captures these strings in a certain group also work? – Aran-Fey Jun 14 '17 at 21:15
  • 1
    Since icu regex isn't able to describe nested parenthesis, there is no solution. – Casimir et Hippolyte Jun 14 '17 at 21:16
  • Given this raw regex `\([a-zA-Z]{0,9})\)` I don't see how parenthesis can be used as delimiters. Parsing `(\([a-zA-Z]{0,9})\))` becomes this `([a-zA-Z]{0,9}))` or parsing `(\\([a-zA-Z]{0,9})\\))` becomes `\\([a-zA-Z]{0,9})\\)` –  Jun 15 '17 at 00:05
  • So, parsing out the _whole_ regex comes before anything. –  Jun 15 '17 at 00:11

0 Answers0