使用正则表达式在 redshift 中用逗号和引号分割字符串

String split with comma and quotes in redshift using Regex

我在 redshift table 中有一个字符串列,例如:

String
["0","0","5","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]
["0","0","0","8","30","0","0","0","0"]
["0","0"]

我想拆分字符串列以在 6 个不同的列中获取字符串的前 6 个字符,如下所示

String Col1 Col2 Col3 Col4 Col5 Col6
["0","0","5","10","20","30","0","0","0","0","0","0","0","0","0","0","0"] 0 0 5 10 20 30
["0","0","0","8","30","0","0","0","0"] 0 0 0 8 30 0
["0","0"] 0 0

我不熟悉 Redshift 和正则表达式概念。任何帮助都会有很大帮助。

尝试 REGEXP_SUBSTR:

select 
  REGEXP_SUBSTR(mystr, '[0-9]+', 1, 1) as col1,
  REGEXP_SUBSTR(mystr, '[0-9]+', 1, 2) as col2,
  REGEXP_SUBSTR(mystr, '[0-9]+', 1, 3) as col3,
  REGEXP_SUBSTR(mystr, '[0-9]+', 1, 4) as col4,
  REGEXP_SUBSTR(mystr, '[0-9]+', 1, 5) as col5,
  REGEXP_SUBSTR(mystr, '[0-9]+', 1, 6) as col6
from mytable;