i using orm doesn't support postgres array, trying hacks add "support".
currently have convert postgres array string array of programming language.
example of postgres array string representation:
{"bla, bla",bla,"bu bu",bu}
so if there spaces, postgres automatically adding quotes, if not, element without quotes.
what regex use array out of this? result should be:
array := []{"bla, bla", "bla", "bu bu", "bu"}
i using go
.
arrays 1 dimensional, like: create table test ( text[] );
i'm not au fait golang, use search regex
(?<=,)(?=[^"](([^"]*"){2})*[^"]*$)|(?<=[^"])(?=,(([^"]*"){2})*[^"]*$)
and replace matches quote "
.
see regex live demo.
then add "[]"
@ front.
assumes (escaped) quotes never appear within values.
Comments
Post a Comment