Home > Back-end >  Get last occurrence for the string after '/' in redshift
Get last occurrence for the string after '/' in redshift

Time:10-09

I am fairly new to regex expressions and always had a trouble to follow. It would be really helpful if I can get answer to the following problem.

I have a column with strings in redshift table and want to extract a certain part of the string(The string that is after the last '/'). For example, I have https://hello.com/my_first_website in my redshift table with the column name as customer_site, from this I want to extract my_first_website as output. Can someone tell me a regex expression that can help me to extract this.

CodePudding user response:

You can use regexp_substr function such as

SELECT regexp_substr('https://hello.com/my_first_website','[^/]*$')
  • Related