I am parsing a file that has lines such as
type("book") title("golden apples") pages(10-35 70 200-234) comments("good read")
And I want to split this into separate fields.
In my example, there are four fields: type, title, pages, and comments.
The desired result after splitting is
['type("book")', 'title("golden apples")', 'pages(10-35 70 200-234)', 'comments("good read")]
It is evident that a simple string split won't work, because it will just split at every space. I want to split on spaces, but preserve anything in between parenthesis and quotation marks.
How can I split this?