1

ADIF是 HAM Operator Radio 的 LOG 标准。

<EOR> 

表示记录的结束。我将一个 ADIF 文件拆分为多条记录

以下记录导致问题。

<CALL:6>SV2JAO<QSO_DATE:8:D>20101001<TIME_ON:4>1736<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E<QSLMSG:62>TNX QSO, 73 FROM GREECE <pse paper qsl card for my collection>

这是使用正则表达式将文件拆分为多个记录的代码。

string[] x = Regex.Split(record.Replace("\n", "").Replace("\r", ""), @"<(.*?):.*?>([^<\t\n\r\f\v]+)").Where(S => !string.IsNullOrEmpty(S)).ToArray();

var dic = new Dictionary<string, string>();
for (int i = 0; i < x.Length; i++)
{
    dic.Add(x[i].ToLower(), x[i + 1]);
    i++;
}

这是 < 和 > 内部 ADIF 单元的问题<TAG:lenghtOfValue>Value

以下是样本记录。

<CALL:6>RK3DXB<QSO_DATE:8:D>20100926<TIME_ON:4>1334<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E

<CALL:6>EA1BRD<QSO_DATE:8:D>20100926<TIME_ON:4>1334<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E

<CALL:6>UV5EHT<QSO_DATE:8:D>20100926<TIME_ON:4>1334<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E

<CALL:5>G4MKI<QSO_DATE:8:D>20100926<TIME_ON:4>1536<BAND:3>30M<MODE:5>PSK31<RST_SENT:4>599 <RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E<QSLMSG:22>73, thanks for the QSO

<CALL:6>EA1BRD<QSO_DATE:8:D>20100926<TIME_ON:4>1636<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E<QSLMSG:19>TNX For QSO TU 73!.

<CALL:5>F5PEZ<QSO_DATE:8:D>20100926<TIME_ON:4>1705<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E<QSLMSG:29>Tnx for the QSO best 73 Andre

<CALL:6>UA3LSX<QSO_DATE:8:D>20100926<TIME_ON:4>1749<BAND:3>30M<MODE:5>PSK31<RST_SENT:3>599<RST_RCVD:0><QSL_SENT:1>Y<QSL_SENT_VIA:1>E<QSLMSG:19>TNX For QSO TU 73!.

如何修改我的代码或正则表达式来解决此问题?

4

1 回答 1

0

解决了 :

            // workaround to prevent from '< something >'  inner ADIF Cell
            string[] x = Regex.Split(record.Replace("\n", "").Replace("\r", ""), @"<([^:]+):\d+[^>]*>").ToArray();
            List<string> l = new List<string>(x);
            l.RemoveAt(0);
            x = l.ToArray();
于 2013-01-19T07:56:22.020 回答