I'm trying to extract certain data from a string with regex. The string looks like this:
some description points goes here
Experience
Company Name
1 year 4 months
software Developer
April 2020 - Present (1 year 1 month)
City Name, State Name, country Name
some description points goes here
StringBuilder sb = new StringBuilder();
string pdfData = string.Empty, pdfData2 = string.Empty;
Regex re = new Regex(regexPattern, RegexOptions.IgnoreCase);
using (PdfReader reader = new PdfReader(path))
{
for (int pageNo = 1; pageNo <= reader.NumberOfPages; pageNo++)
{
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
pdfData += PdfTextExtractor.GetTextFromPage(reader, pageNo, strategy);
Match match = re.Match(pdfData);
if (match.Success)
{
pdfData2 += match.Value;
}
}
}
I would like to extract the company name, duration (1 year 4 months), and designation (Software Developer), where this regex pattern matches (April 2020 - Present (1 year 1 month)). When this pattern matches, I want to get the three lines before this pattern.
I have tried string regex Pattern = @"[ADFJMNOS][a-z]{2,8}\s[12][0-9]{3}\b";. This gets me only April 2020.