Shorten Home Depot URL

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

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

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.


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