原日志格式如下
11/12/2004, Simon
  *) Added this file.
11/16/2004, Johnason
  *) Support saving TDF file
    Changed Files: SystemConfig.cpp/h
    Added files: TDF.cpp/h
    Description:
      - Add NIST_SUPPORT in cls_cls.cfg
  - Add cls_nist.cfg. A sample and explaination is put in misc
  - Add a new class CTDF, which calls some functions of lscvt.lib
        and tdf.lib.
    Comments:
      - CTDF need to be enhanced. The basic idea is to use a base class for
        initing, reading existing TDF file and saving repacked TDF file. No
        binding data (a virtual function) in base class. Three new class will
        be derived from the base class to bind three kinds of data: from
        WinCtrlSet, cls_nist.cfg, images. Then ClsMain and ClsDataEntry can
        call different class as they required.11/23/2004, Johnason
  *) Florida payment interface
    Changed files: SystemConfig.cpp/h
    Description:
  - It map FirstName, LastName, MidName, SufName before. Now it only map
        the Name field.  *) Flat App Version
    Changed files: SystemConfig.cpp/h
    Description:
  - Read nFlatAppVersion in Cls_cls.cfg
需要得到如下格式 CHANGES.txt包含了我公司开发人员对一个代码库的修改历史。请用C#来编写一个词法分析(Parse)程序来提取以下要求的字段组成的修改纪录,并将结果写入一个或多个文件中。字段之间(field)用'|'分隔。具体分析的结果要求如下:
  
  a) 每个纪录应包含下列字段:

Change ID:  给每项修改记录分配一个唯一的序号。
Changed Date:  提取原始修改记录中的MM/DD/YYYY格式的日期。
Changed By: 提取原始修改记录中紧跟在日期之后的开发人员名字。
Summary:         提取原始修改记录中由'*)'给出的修改摘要。
Description:     提取原始修改记录中由'Description:'给出的修改说明。
Purpose:         提取原始修改记录中由'Purpose:'给出的修改目的说明。
Changed Files:   提取原始修改记录中由'Changed Files:'给出的修改文件列表。
Added Files:     提取原始修改记录中由'Added Files:'给出的新增文件列表。  b) 请用'*)'作为一项修改的标示(而不是日期)。因为一个开发人员在同一天可以做多项修改。在同一日期下的多个'*)'应被分割成多个修改纪录。  c) 在"Description:"下可能会有多项由"-"给出的说明项。
望高手赐教,小弟感激不尽

解决方案 »

  1.   

    以下的没有写完,后面的你自己完善  string str = @"11/12/2004, Simon 
      *) Added this file. 
    11/16/2004, Johnason 
      *) Support saving TDF file 
        Changed Files: SystemConfig.cpp/h 
        Added files: TDF.cpp/h 
        Description: 
          - Add NIST_SUPPORT in cls_cls.cfg 
      - Add cls_nist.cfg. A sample and explaination is put in misc 
      - Add a new class CTDF, which calls some functions of lscvt.lib 
            and tdf.lib. 
        Comments: 
          - CTDF need to be enhanced. The basic idea is to use a base class for 
            initing, reading existing TDF file and saving repacked TDF file. No 
            binding data (a virtual function) in base class. Three new class will 
            be derived from the base class to bind three kinds of data: from 
            WinCtrlSet, cls_nist.cfg, images. Then ClsMain and ClsDataEntry can 
            call different class as they required. 11/23/2004, Johnason 
      *) Florida payment interface 
        Changed files: SystemConfig1.cpp/h 
        Description: 
      - It map FirstName, LastName, MidName, SufName before. Now it only map 
            the Name field.   *) Flat App Version 
        Changed files: SystemConfig2.cpp/h 
        Description: 
      - Read nFlatAppVersion in Cls_cls.cfg ";
                //'Regex reg = new Regex(@"(\d{2}/\d{2}/\d{4}),([\s\S]*?)\*\)([^\r\n]+?)\r\n([\s\S]*?)(?=$|\d{2}/\d{2}/\d{4})");
                Regex reg = new Regex(@"(\d{2}/\d{2}/\d{4}),([\s\S]*?)\*\)([\s\S]*?)(?=$|\d{2}/\d{2}/\d{4})");
                MatchCollection ms  = reg.Matches(str);
              //  Response.Write(ms.Count.ToString());
                DataTable dt = new DataTable();
                dt.Columns.Add("ChangedDate");
                dt.Columns.Add("ChangedBy");
                dt.Columns.Add("Summary");
                dt.Columns.Add("Description");
                dt.Columns.Add("Purpose");
                dt.Columns.Add("ChangedFiles");
                dt.Columns.Add("AddedFiles");            string sDate = string.Empty;
                string ChangeBy  = string.Empty;
                reg = new Regex(@"\*\)([^\r\n]*?)\r\n([\s\S]*?)(?!\*\)|$)");
                foreach (Match m in ms)
                {
                     sDate= m.Result("$1");
                     ChangeBy = m.Result("$2");
                                    
                    MatchCollection ms1 = reg.Matches(m.Value);                foreach (Match m1 in ms1)
                    {
                        DataRow row = dt.NewRow();
                        row["ChangedDate"] = sDate;
                        row["ChangedBy"] = ChangeBy;
                        row["Summary"] = m1.Result("$1");
                        dt.Rows.Add(row);
                    }
                   
                    
                   
                }            DataGrid dg = new DataGrid();
                dg.DataSource = dt.DefaultView;
                this.form1.Controls.Add(dg);
                dg.DataBind();