Answer the question
In order to leave comments, you need to log in
Why doesn't the regular expression that works in regex101 work?
There is a ready-made regular expression that works as shown in the figure, but when you write the same expression in C#, it outputs the entire text of the first line.
Code in C#:
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
string pattern = @"(?<=\s)\d(\.|-(\d))\s.*" + surname + @".*\d";
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
foreach (Match match in Regex.Matches(currentText, pattern, RegexOptions.IgnoreCase))
{
for (int i = 0; i < match.Groups.Count; i++)
resultText += match.Value + "\n";
}
text.Append(resultText);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question