Exemplo n.º 1
0
        }//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);
            }
        }
Exemplo n.º 2
0
 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