type Param = { str: string; userId: string | number; }; export default function replaceDatasquirelDbName({ str, userId, }: Param): string { const dbNamePrefix = process.env.DSQL_USER_DB_PREFIX; const userNameRegex = new RegExp(`${dbNamePrefix}\\d+_`, "g"); const newPrefix = `${dbNamePrefix}${userId}_`; return str.replace(userNameRegex, newPrefix); }