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))
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With