示例#1
0
文件: Finer.cs 项目: katecod/C_Finder
        }//pdf

        private void GetIndexs(takesting tkstr, Match mtch, string AllData)
        {
            int beforeAndAfter = 30;

            if (mtch.Index > beforeAndAfter)
            {
                tkstr.PutStarti(mtch.Index - beforeAndAfter);
            }
            else
            {
                tkstr.PutStarti(0);
            }
            if (AllData.Length > (mtch.Length + mtch.Length + beforeAndAfter))
            {
                tkstr.Putlasti(mtch.Length + mtch.Length + beforeAndAfter);
            }
            else
            {
                tkstr.Putlasti(AllData.Length);
            }
        }
示例#2
0
文件: Finer.cs 项目: katecod/C_Finder
 private void Easyread(answer thisansw, string path, string TheWord)
 {
     try
     {
         if (File.ReadAllText(path).Contains(TheWord))
         {
             string AllData = File.ReadAllText(path);
             AllData = GetClean(AllData);
             foreach (Match mtch in Regex.Matches(AllData, TheWord))
             {
                 takesting tkstr = new takesting();
                 GetIndexs(tkstr, mtch, AllData);
                 string answ = AllData.Substring(tkstr.GetStarti(), tkstr.GetLasti());
                 thisansw.addResult(answ);
             }
         }
     }
     catch (Exception)
     {
         WriteInFile("ERROR:" + path, true);
         throw;
     }
 }//txt, tex