Remove duplicate rows from google spreadsheet

I needed to remove duplicate rows from a google spreadsheet and regex the last part of the string for each row

I had a specific work case where I should go through a long list of urls and had to extract the string from the last “/”. I was given a long list of URLs, and with no intention of going through each of them manually, I decided to speed up things a bit with a little Google Spreadsheet scripting. I then noticed that there where duplicate URLs in my list – eeek, I need to remove duplicate rows.

This script I can call from within my cells on the spreadsheet. I simply added the following in the row next to my urls, and copied it down to the entire column (thus automatically adding the correct cell)

I was able to remove duplicate rows and clean the cells with the regular expression script.

This gave me a list of cleaned strings that I could use for other automation and the script I can use for cleaning in my daily work.