Missing } in quantified repetition. The error occurred while parsing the regular expression: '{>>>HERE>>>.*}'

Viewed 131

I get this error:

Missing } in quantified repetition. The error occurred while parsing the regular expression: '{>>>HERE>>>.*}'. Details:

When running:

select regexp_substr(jsons_arrays,'\{.*\}',1,1)
from table

Field json_arrays is an invalid json such as:

{'a': '20', 'b': '30'}, {'b': '1'}, {'a': '112', 'b': '34'}

The goal is to split this field into three valid jsons:

  1. {'a': '20', 'b': '30'}
  2. {'b': '1'}
  3. {'a': '112', 'b': '34'}

Maybe is the application of the posix substring in the regexp_substr function? How can I add the pattern of 'anything between {}'

1 Answers

You need to double-escape {} on Redshift.

For example, '\\{\\} to match {} literally.

Related