Reputation: 1
I have a string: 'ABC/DEF-GHI/GHI/IJK-LMN/GHI'
I want to delete the repeated occurrence of GHI followed by DEF-GHI, but not delete the last GHI because it is not adjacent to another GHI.
Expected output: 'ABC/DEF-GHI/IJK-LMN/GHI'
I would like to achieve this using REGEX expressions.
I tried this and adjusted this many ways but I'm still not seeing the expected output, I'm new to both regex and snowflake.
SELECT REGEXP_REPLACE('ABC/DEF-GHI/GHI/IJK-LMN/GHI', '([A-Za-z]{3})(\/)\1', '\\1') AS cleaned_text;
TIA.
Upvotes: 0
Views: 39