I have many PDF files containing date records which can be imported and result in a list like the one shown in the example Notebook attached. I am interested in extracting a list of the first year fields:
{2019, 2023}.
All the StringExpressions I have built extract the second year. I have tried qualifying the matching pattern with Shortest and other modifications but always extract the list {“2020”, “2023”}.
Can someone build a StringExpression that extracts {2019, 2023} or suggest an alternate manner of extracting the first year field? Note the exact position of the year is not known because cities may be of varying word length. The year needs to be extracted based on the text and date contents.
Some general guidance or references as to how one extracts the exact fields one wants from a text expression would also be helpful. My general approach is to take an example text string I wish to parse and replace each field with a corresponding matching StringExpression which leads to hit and miss results.
Example Notebook.