I recently had to delete a large number of databases in a PostgreSql database.
I found the code below very useful. It will list a sequence of SQL DROP DATABASE statements, one for each of the databases with a name starting with "database_name_starting_with_this".
The list of statements can be copied to psql a executed by pasting.
I want to warn you this can be dangerous, so go through the list of statements one by one, before you execute them.