使用模式将字符串拆分为 Postgres 中的新行

Split String using Pattern into new line in Postgress

我正在使用下面的查询来获取如下输出。我想制作函数,以便我将传递该字符串并获得预期输出的输出。 {} 括号中的每个数据都需要显示在每一行中。

字符串:- {$..Properties[*]}-{$..Layer_Index}+{$..Name==Value()}/{$..Properties(Name==True)}

预期输出:-

您可以使用 regexp_matches()

select (regexp_matches(input, '\{($[^\}]+)\}', 'g'))[1]

其中 input 是您要解析的字符串。

regexp_matches() returns 每行多个匹配项作为一个数组。 (..)[1] 然后选择该数组的第一个元素。

我认为这也适用于 Postgres 9.2。

Online example