String extraction in dremio

Hello guys ,

I will appreciate any idea on how to extract the first email the delimiter is “-” , but the keep in mind the delimiter is also present within the mail.

yello-name@hello.com-school@hello.com

This was my first execution but it stripped other part of the string,where it found “-”

select (case when position('-' in 'yello-name@hello.com-school@hello.com') <> 0 then substr('yello-name@hello.com-school@hello.com', position('-' in 'yello-name@hello.com-school@hello.com')-1 end)

output → “yello”

In SQL Sever the query below works, but I am stuck with implementing it dremio

Select substring('yello-name@hello.com-school@hello.com',0,PATINDEX('%.%-%','yello-name@hello.com-school@hello.com')+4)

Any help will be of great value,

Thank you.
Samson

Thank you guys I think I figured out the issue.

(case when position('-' in 'yello-name@hello.com-school@hello.com') <> 0 then substr('yello-name@hello.com-school@hello.com',0,strpos('yello-name@hello.com-school@hello.com' ,'.')+3) end) email