I'm trying to clean up a database of links and I need to remove everything after the third instance of a /

I've been googling but haven't found anything like this yet.

Thank you.