private void button2_Click(object sender, EventArgs e) { try { var helper = new WordHelper("20210220 125048 blank-zayavleniya-o-priyome-na-rabotu.doc"); List <string> textBlocks = helper.ReadText(); string to = null, from = null, prof = null, dateFrom = null, months = null, salary = null, date = null; foreach (var block in textBlocks.Where(b => !string.IsNullOrEmpty(b))) { Match m = null; if (string.IsNullOrEmpty(to)) { m = _regTo.Match(block); if (m != null && m.Success) { to = m.Groups["ORG"].Value; } } if (string.IsNullOrEmpty(from)) { m = _regFrom.Match(block); if (m != null && m.Success) { from = m.Groups["FIO"].Value; } } if (string.IsNullOrEmpty(prof)) { m = _regBody.Match(block); if (m != null && m.Success) { prof = m.Groups["PROF"].Value; dateFrom = m.Groups["DATE_FROM"].Value; } } if (string.IsNullOrEmpty(months)) { m = _regRow.Match(block); if (m != null && m.Success) { months = m.Groups["MONTHS"].Value; salary = m.Groups["SALARY"].Value; } } } for (int i = textBlocks.Count - 1; i >= 0; i--) { var m = _regDate.Match(textBlocks[i]); if (m != null && m.Success) { date = m.Groups["DATE"].Value; } } Console.WriteLine($"to = {to}, from = {from}, prof = {prof}, dateFrom = {dateFrom}, months = {months}, salary = {salary}, date = {date}"); } catch { } }