提取并格式化文本文件中的字符串?

时间:2013-11-13 12:12:17

标签: c#

我有一个格式的文本文件 CODE:8000012016 502错误的网关

502 Bad Gateway

找不到主机或连接失败

CODE:8000012146 502错误的网关

502 Bad Gateway

找不到主机或连接失败

CODE:8000023700 502错误的网关

502 Bad Gateway

找不到主机或连接失败

。 。 。 。 。 。 。 。 CODE:8001129584 { “事项标识”: “0D004B66AA326A34”, “版本”: “1.6”, “错误”:{ “system_unavailable”:真实的, “no_tickets”:真实的, “无效”:{ “票务”:真正}}, “命令” : “event_authenticate”}

CODE:8001129586 { “事项标识”: “0D004B66AA326A34”, “版本”: “1.6”, “错误”:{ “system_unavailable”:真实的, “no_tickets”:真实的, “无效”:{ “票务”:真正}}, “命令” : “event_authenticate”} 。 。 。 。

我必须分开这两种格式并保存在新的不同文本文件中。

1 个答案:

答案 0 :(得分:0)

好的,请详细说明......如我所见,您可以搜索HTML标签。

例如:

foreach(LineOfText line in text)
{
    foreach(Word in line)
    {
        if(Word is HtmlTag)
        {
            mark current line as type1;
            put current line in string1;
        }
        else
        {
            mark current line as type2;
            put current line in string2;
        }
    }
}

SaveString(string1);
SaveString(string2);