package org.jeecg.config.saas;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class DbUrlUtil {
    /**
     * 从 JDBC URL 中提取数据库名
     */
    public static String extractDbName(String dbUrl) {
        Pattern p = Pattern.compile("jdbc:.*?//.*?/(.*?)(?:\\?.*)?$");
        Matcher m = p.matcher(dbUrl);
        if (m.find()) {
            return m.group(1);
        }
        throw new IllegalArgumentException("无法从 URL 中提取数据库名: " + dbUrl);
    }
}
