import re

def extract_and_format_strings(input_string):
    # 使用正则表达式匹配 batteryInfo. 形式的字符串，包括空格和非贪婪匹配
    matches = re.findall(r'batteryInfo\.[^ ,]+', input_string)
    # 将匹配到的字符串用空格连接
    result = '\n'.join(matches)
    return result

# 示例输入字符串
input_string = """
        testNapi.register(0, (a) => {
            var t = batteryInfo.batterySOC - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });

        // 充电状态差值判断
        testNapi.register(1, (a) => {
            var t = batteryInfo.chargingStatus - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });

        // 电池健康状态差值判断
        testNapi.register(2, (a) => {
            var t = batteryInfo.healthStatus - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });

        // 电池插入类型差值判断
        testNapi.register(3, (a) => {
            var t = batteryInfo.pluggedType - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });

        // 电池电压差值判断
        testNapi.register(4, (a) => {
            var t = batteryInfo.voltage - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });

        // 电池技术判断
        testNapi.register(5, (a) => {
            var f;
            if (a === batteryInfo.technology)
                f = 1;
            else
                f = 0;
            return f === 1;
        });

        // 电池温度差值判断
        testNapi.register(6, (a) => {
            var t = batteryInfo.batteryTemperature - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });

        // 电池是否存在判断
        testNapi.register(7, (a) => {
            return batteryInfo.isBatteryPresent === a;
        });

        // 电池容量等级差值判断
        testNapi.register(8, (a) => {
            var t = batteryInfo.batteryCapacityLevel - a;
            var f;
            if (t > 0)
                f = 1;
            else if (t == 0)
                f = 0;
            else
                f = -1;
            return f === 0;
        });"""
# 提取并格式化字符串
formatted_string = extract_and_format_strings(input_string)
print(formatted_string)
