depend-cleanup.sh: Extend clean_dep to support a custom regex
This will avoid having to duplicate the loop every time the default
regex isn't good enough, and will be used by upcoming commits.
(cherry picked from commit cc30f4ae6790cf4f19bc4787d7528dfea79ef27a)