Skip to main content
deleted 12 characters in body
Source Link
James Z
  • 12.3k
  • 10
  • 26
  • 47

I have string column "49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248"

this string column has 3 values separate by ",". (value1,value2,value3). there is no guarantees that vaule2 and value3 need to be present always. but value1 does always.

so i need to split this single column into 3 different columns keeping the above conditions of thier existancetheir existence in mind and they need to be separated by before "," into a new column.

i have sofarso far wrote as

select regexp_extract('49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248', '^(.+?),') as value1

select regexp_extract('49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248', '^(.+?),') as value1

but after that my logic and thinking giving errors and no luck to me. please suggest.

I have string column "49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248"

this string column has 3 values separate by ",". (value1,value2,value3). there is no guarantees that vaule2 and value3 need to be present always. but value1 does always.

so i need to split this single column into 3 different columns keeping the above conditions of thier existance in mind and they need to be separated by before "," into a new column.

i have sofar wrote as

select regexp_extract('49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248', '^(.+?),') as value1

but after that my logic and thinking giving errors and no luck to me. please suggest.

I have string column "49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248"

this string column has 3 values separate by ",". (value1,value2,value3). there is no guarantees that vaule2 and value3 need to be present always. but value1 does always.

so i need to split this single column into 3 different columns keeping the above conditions of their existence in mind and they need to be separated by before "," into a new column.

i have so far wrote as

select regexp_extract('49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248', '^(.+?),') as value1

but after that my logic and thinking giving errors and no luck to me.

Source Link
ajk
  • 21
  • 1

need regexp_extract help, beginner

I have string column "49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248"

this string column has 3 values separate by ",". (value1,value2,value3). there is no guarantees that vaule2 and value3 need to be present always. but value1 does always.

so i need to split this single column into 3 different columns keeping the above conditions of thier existance in mind and they need to be separated by before "," into a new column.

i have sofar wrote as

select regexp_extract('49b8b35e-b62c-4a42-9d73-192d131d127a,03c8a7e0-5153-11ec-873a-0242ac11000a,eec8aee4-0500-4940-b319-15924cc2d248', '^(.+?),') as value1

but after that my logic and thinking giving errors and no luck to me. please suggest.