Is there a way in Presto or SQL to remove the last backslash only when it is preceded by a character and keep it otherwise?
I am using regexp_replace in presto. So for example if x = '/' The expression should return '/' and if x = 'beta/alpha/' it should return 'beta/alpha'
I am using select regexp_replace ([expression], '[\/]$', '').
This returns an empty string when there is only a backslash and removes the backslash from the end of the string if the expression has some characters before the backslash.