I'm working with a varchar column in AWS Redshift. Each string in it has at least one hyphen (-
).
I want to keep the substring after the first hyphen. For example:
00-11-22-33
->11-22-33
00-112233
->112233
The solutions to this question do not work when there are multiple hyphens in a string.
For instance:
select
split_part('00-11-22-33', '-', 2) as attempt1 -- returns '11'
, regexp_replace( '00-11-22-33', '.*-', '') as attempt2 -- returns '33'
;
I'm looking for a solution that returns 11-22-33
.