Denodo Dive Split function URL

205 Views Asked by At

I'm trying the below code to select the last part of the URL:

select 'http://www.XX.com/download/apple-Selection-products/beauty-soap-ICs' ,  field_1[0].string
from
(
select SPLIT('([^\/]+$)', 'http://www.XX.com/download/apple-Selection-products/beauty-soap-ICs')field_1 

  )

However, my result isn't coming as expected.

http://www.XX.com/download/apple-Selection-products/beauty-soap-ICs

result should be :

beauty-soap-ICs

but I'm getting Wrong Result.

Any help will be appreciated. The URL can and can't end in a /.

1

There are 1 best solutions below

2
On

You can use the REGEXP function here:

SELECT REGEXP('http://www.XX.com/download/apple-Selection-products/beauty-soap-ICs', '.*/([^/]+)/?$', '$1') AS result

See the regex demo

Details:

  • .* - any zero or more chars other than line break chars as many as possible
  • / - a / char
  • ([^/]+) - Group 1 ($1 refers to this group value)" one or more chars other than /
  • /? - an optional / char
  • $ - end of string.