如何读出带文本中的以下字段:(FeeUser_ID)MSISDN ,(DestUser_ID)MSISDN,ActionID,ActionReasonID,SPServiceID,AccessMode,FeatureStr
文本格式:===================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 999
Dest_Address:
DeviceType: 400
DeviceID: 917014
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 1
ActionReasonID: 1
SPID: 917014
SPServiceID: 6102
AccessMode: 3
FeatureStr: (null)
===================Trace========================================Trace=====================
SOAP Body:
MsgType: SyncOrderRelationReq
Version: 1.5.0
Send_Address:
DeviceType: 0
DeviceID: 999
Dest_Address:
DeviceType: 400
DeviceID: 917014
FeeUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
DestUser_ID:
UserIDType: 1
MSISDN: 13823380009
PseudoCode: (null)
LinkID: SP
ActionID: 1
ActionReasonID: 1
SPID: 917014
SPServiceID: 6102
AccessMode: 3
FeatureStr: (null)
===================Trace=====================谢谢各位老大啊

解决方案 »

  1.   

    如何读出带文本中的以下字段
    ==========================?
    不是很清楚你的意思
    如果就是一个普通的文本文件,我觉得这样比较麻烦
    因为文件中两个字段没关系
    难道是赋值吗?用ini还可以
      

  2.   

    assignfile(f,syspath+'YourFile.ini);
            reset(f);
            read(f,s);                  //接收字符串
            closefile(f);
      

  3.   

    uses RegExpr;...var
      Expr: TRegExpr;
      TS: TStrings;
    begin
      TS := TStringList.Create;
      try
        { 读入文件 }
        TS.LoadFromFile('文件名.txt');
        { 建立正则表达式对象 }
        Expr := TRegExpr.Create;
        { 用于读取 (FeeUser_ID)MSISDN 的正则表达式 }
        Expr.Expression := 'FeeUser_ID:.*?MSISDN: (\d+)';
        try
          { 执行正则表达式匹配 }
          Expr.Exec(moInput.Text);
          { 输出结果 }
          Edit1.Text := Expr.Match[1];  // 这里是显示在 Edit1 上
        finally
          Expr.Free;
        end;
      finally
        TS.Free;
      end;
    end;正则表达式类可在Delphi园地下载:
    http://www.delphifans.com/SoftView/SoftView_500.html
      

  4.   

    对不起!上面的例子中请将
    Expr.Exec(moInput.Text);
    改成
    Expr.Exec(TS.Text);要读取其他内容,只要更换例子中的 Expr.Expression 即可,如下:用于读取 (DestUser_ID)MSISDN 的正则表达式:
    Expr.Expression := 'DestUser_ID:.*?MSISDN: (\d+)';ActionID 的:
    Expr.Expression := 'ActionID: (\d+)';ActionReasonID 的:
    Expr.Expression := 'ActionReasonID: (\d+)';SPServiceID 的:
    Expr.Expression := 'SPServiceID: (\d+)';AccessMode 的:
    Expr.Expression := 'AccessMode: (\d+)';FeatureStr 的:
    Expr.Expression := 'FeatureStr: ([^\n\r]*)';