I work with historical burial records and want to work with Ages in these documents for calculating rough birth dates. This will be within vba code.
Sometimes, these are not simply an integer but are strings showing years, months, weeks and/or days.
An example using all of these, with any spaces removed, is below.
11years3months2weeks3days
The years/months/weeks/days texts could be a list of abbreviations such as mths/m, wks/w etc.
If, as in the example, more than one of these time periods appears, they will be in that order (largest to smallest time period) and the numeric values should make sense ie up to 120 at most for years, 1-23 for months(children can have ages such as 18 months), probably up to 51 weeks, and probably up to 365 days.
However, these are all optional so there could be exams such as below:
1mth3dys
2years6months
3wks5days
I am sure regex can check these formats. I have had some ideas but am not experienced in regex.
Can a regex expression be used to, not just identify tye format but to get the numeric values for any years/months/weeks/days in the text? If so, what code could be used in a vba function to do this?
Cheers