I need to extract substring from list of file paths. Paths are like "\rootfolder\subfolder". Need extract substring as "rootfolder" ( between 2nd backslash and 3rd backslash.
select SUBSTR('\\rootfolder\subfolder\', 3, (REGEXP_INSTR('\\rootfolder\subfolder\','\', 1, 3) - 3)) from table;
But this expression didn't give right result in Snowflake. problem is with backslash character.
Using SPLIT_PART:
Output:
Dollar quoting was used to avoid doubling
\.