Home > Blockchain >  How can I split a string into two based on a character inbetween using REGEXP_EXTRACT?
How can I split a string into two based on a character inbetween using REGEXP_EXTRACT?

Time:03-18

I need to split a string into two based on a character and I need to do this without using enter image description here

CodePudding user response:

Consider below approach

select 
  arr[offset(0)] as splitstring1,
  arr[safe_offset(1)] as splitstring2
from  your_table,
unnest([struct(regexp_extract_all(string, r'[^=] ') as arr)])          

if applied to sample data in your question - output is

enter image description here

  • Related