package com.example.sse.core;

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

public class ChannelIdParser {
    private static final Pattern CHANNEL_CODE = Pattern.compile("\\[(\\d{1,10})\\]");

    private ChannelIdParser() {}

    public static String extractChannelId(String line) {
        if (line == null) return null;
        Matcher m = CHANNEL_CODE.matcher(line);
        if (m.find()) {
            // group(1)을 그대로 반환
            return m.group(1);
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println("ChannelIdParser.main: " + extractChannelId("2025-02-05 13:00:00.055488 INFO  SM_01@04824    [0015] [_std_serviceLog.dxml][데이터 송수신(가변)][00002364][sendnreceive-ex] End Event[ok] Elapsed[10ms] []"));
    }
}
