regexp_matches better way to get rid of returning curly brackets

postgresql

Solution

`regexp_matches()` returns an array of all matches. The string representation of an array contains the curly braces that's why you get them.

If you just want a list of all matched items, you can use `array_to_string()` to convert the result into a "simple" text data type:

array_to_string(regexp_matches(note, '[0-9a-z \r\n]+', 'i'), ';')

If you are only interested in the first match, you can select the first element of the array:

(regexp_matches(note, '[0-9a-z \r\n]+', 'i'))[1]

Problem

Is there some better way to trim `{""}` in result of regexp_matches than: ``` trim(trailing '"}' from trim(leading '{"' from regexp_matches(note, '[0-9a-z \r\n]+', 'i')::text)) ```

Original source