split(regexp_replace ) Like Function In Presto : 331

273 views Asked by At

Is there any way to split values based on consecutive 0's in presto.Minimum 6 digits should be there in first split, if digit count is less than 6 than need to consider some 0's as digit then split if digit count is >= 6 then just need to split in 2 groups. below query is working as expected in Hive.But I am not able to do the same using presto.

 select low as orginal_Value,
 split(regexp_replace(low,'(\\d{6,}?)(0+)$','$1|$2'),'\\|')  Output_Value  from test;

enter image description here

Presto Query:

presto> SELECT regexp_split('1234567890000', '(\d{6,}?)(0+)$') as output;

output
[1234567890000]
(1 row)
1

There are 1 answers

0
Sonu On

It worked Now.

select split(regexp_replace('1234567890000','(\d{6,}?)(0+)$','$1|$2'), '|') as output;
enter code here
   
output
-------------------
[123456789, 0000]