SQLTeam.com | Weblogs | Forums

Pattern matching for a URL

Hi,

I have a column in my data that has URLs. I need only those URLs that end with: /installers

The column has many URLs with "/installers" in it. But I don't want any characters after "/installers"

I tried pattern matching with this: '%[/]installers[^A-Z0-9]', but I didn't get the intended results.

Below is a picture of the URL that I'm capture in the data:

pic1

Any help is appreciated. Thanks

You can use the REVERSE function for this;

DROP TABLE IF EXISTS #a

SELECT 'http://google.com/installers' AS SearchString INTO #a

SELECT 
	* 
FROM #a a 
WHERE REVERSE(SearchString) LIKE REVERSE('%/installers')