public static function buildBasedIntRegex($base)
    {
        assert(2 <= $base && $base <= 16);
        $regex = '/(?i:[0-';
        if ($base <= 10) {
            $regex .= (string)$base-1;
        } else {
            $regex .= '9a-' . strtolower(dechex($base-1));
        }
        $regex .= '])+/';
        return $regex;
    }