正则表达式用于postgres数组

I am using ORM which doesn't support postgres array, so I am trying to do some hacks to add "support".

Currently I have to convert postgres array string into array of programming language.

Example of postgres array string representation:

{"bla, bla",bla,"bu bu",bu}

So if there are spaces, postgres is automatically adding quotes, if not, then element is without quotes.

What regex you would use to get array out of this? So result should be:

array := []{"bla, bla", "bla", "bu bu", "bu"}

I am using Go.

Arrays are one dimensional, so something like: CREATE TABLE test ( something text[] );

I'm not au fait with golang, but use this search regex

(?<=,)(?=[^"](([^"]*"){2})*[^"]*$)|(?<=[^"])(?=,(([^"]*"){2})*[^"]*$)

and replace matches with a quote ".

See regex live demo.

Then add "[]" at the front.

Assumes (escaped) quotes never appear within values.