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++;
}
&lt;的问题是什么?和&gt;内部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!.
如何修改我的代码或正则表达式以解决此问题?
答案 0 :(得分: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();