How to allow a user to create databases only with a certain prefix?
PostgreSQL does not allow you to do this inside PostgreSQL.  You cannot create a database inside a transaction so procedural language functions cannot create databases or drop databases.  I hope some day this is corrected, but it is the one piece of DDL that does not work inside a transaction.

What this means is you have to do it from outside the database with a separate application that runs whatever checks you want to run.  Some key things to keep in mind are:


You probably want to have a dedicated user (role with login, noinherit) for the database creation process.
You do not want to give the permission to create dbs to the general users.
The script should create the database and then ALTER DATABASE ... OWNER TO ... in order to ensure that the user has full permissions to it.