private void DisasembleRegularSeach(string str) { Regex regularString = new Regex(@"Area|Perimeter|\d+\,*\.*\d*"); Match regularSeachString = regularString.Match(str); ConstructRow constructRow = new ConstructRow(); bool first = true; bool second = false; while (regularSeachString.Success) { if (first) { constructRow.StrNumber = int.Parse(regularSeachString.Value); first = false; second = true; regularSeachString = regularSeachString.NextMatch(); } if (second) { constructRow.StrTypeCalculation = regularSeachString.Value; first = false; second = false; regularSeachString = regularSeachString.NextMatch(); } if (!first && !second) { constructRow.StrValue = double.Parse(regularSeachString.Value); regularSeachString = regularSeachString.NextMatch(); } ListStreamOpen.Add(constructRow); } regularSeach = regularSeach.NextMatch(); }
private List<ConstructRow> CreateListText(string fileFolder) { StreamReader streamReader = new StreamReader(fileFolder); string textFromFile = streamReader.ReadToEnd(); streamReader.Close(); Regex regular = new Regex(@"\s*\d+\s*(Area)*(Perimeter)*\s*\d+\,*\.*\d*\r\n"); regularSeach = regular.Match(textFromFile); int counter = CountRowsText(textFromFile); while (regularSeach.Success) { DisasembleRegularSeach(regularSeach.Value); } ConstructRow constrictRow = new ConstructRow(); ListStreamOpen.Sort(constrictRow); return ListStreamOpen; }