?? parsemsg.cs
字號(hào):
/* ************************************************************************
* 描述: 消息解析器
* 創(chuàng)建: sodak 2006-12-30
*
* 開 發(fā) 歷 史
* ------------------------------------------------------------------------
*
* 修改日期 修 改 內(nèi) 容 修改人
* ------------------------------------------------------------------------
*
*
*****************************************************************************/
using System;
using System.Text;
using System.Collections;
using System.Text.RegularExpressions;
using System.Configuration;
namespace TQQ
{
/// <summary>
/// 消息解析器
/// </summary>
public class ParseMsg
{
//private static string regStr1 = ConfigurationSettings.AppSettings["regStr"];
/// <summary>
/// 解析窗口消息
/// </summary>
/// <param name="strMsg"></param>
/// <returns></returns>
public static ArrayList Parse(string strMsg)
{
string regStr = ConfigurationSettings.AppSettings["regStr"];//@"\r\n(?<name>.*?)\((?<num>\d+)\)\s(?<hh>\d{2})\:(?<mm>\d{2})\:(?<ss>\d{2})\r\n(?<msg>[\s\S]*?)";
//創(chuàng)建表達(dá)式
Regex r = new Regex(regStr,RegexOptions.RightToLeft);
MatchCollection mc = r.Matches(strMsg);
ArrayList MsgList = new ArrayList();
//搜索所有數(shù)據(jù)
for (int i = 0; i < mc.Count; i++)
{ string sdate = DateTime.Now.ToString("yyyy-MM-dd");
string sHour = mc[i].Groups["hh"].Value;
string sMinute = mc[i].Groups["mm"].Value;
string sSecond = mc[i].Groups["ss"].Value;
QQMsg msg = new QQMsg();
msg.Name = mc[i].Groups["name"].Value;
msg.Number = mc[i].Groups["num"].Value;
msg.SendTime = DateTime.Parse(sdate + string.Format(" {0}:{1}:{2}",sHour,sMinute,sSecond));
msg.Msg = mc[i].Groups["msg"].Value;
MsgList.Add(msg);
}
return MsgList;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -