Find 3rd Instance of '/'

0

Please login or register to vote for this query.

(click on this box to dismiss)

DevOps Meta

Q&A about the site for software engineers working on automated testing, continuous delivery, service integration and monitoring, and building SDLC infrastructure

DECLARE @str VARCHAR(50)
SET @str = 'https://aws.amazon.com/marketplace/ppprodview-'
SELECT 
  case when
      LEN(@str) - LEN(REPLACE(@str, '/', '')) < 5 then @str
  else    
SUBSTRING(@str, 0, CHARINDEX('/', @str, CHARINDEX('/', @str, CHARINDEX('/', @str, CHARINDEX('/', @str, CHARINDEX('/', @str, 0) + 1) + 1) + 1) + 1))
end

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results