Shorten Home Depot URL

Is there a way to take a Home Depot URL like this:

https://www.homedepot.com/p/1-2-in-x-5-ft-Conduit-Electrical-Metallic-Tubing-Steel-0550005000/202068069

...and remove everything between "p/" and the final "/" to return this:

https://www.homedepot.com/p/202068069

This should work:

The find line: ^(.*?\/p).*\/?(\/.*)$
The replace line: $1$2

The example assumes you have the URL in a variable, but you could easily change it to work off clipboard, etc.

-rob.

That works perfectly - thank you!

1 Like

and another approach is to refer to the parts of the URL which we want to drop or keep by their numeric index.

( splitting on "/" )

Parts of URL dropped by numeric index.kmmacros (3.5 KB)


For a subroutine to generalise variable array slices, see:

1 Like

Awesome - thanks ComplexPoint!

1 Like