I'm trying to extract the date from the following strings but to no avail.
const strs = [
`X
March 17th 2011
`,
`X
2011
`,
`X
March
2011
`,
];
console.log(strs.map(s =>
s.match(/X\s+([a-zA-Z]+?\s*[a-zA-Z0-9]+)?\s*(\d+)/))
);
The problem is with the first match, currently it is
[
"X\n March 17",
"March",
"17"
]
while it should be
[
"X\n March 17th 2011",
"March",
"17th",
"2011"
]
Any help would be appreciated.
full_month_name day_ending_in_th 4_digit_yearwith the first two fields optional? Or is the logic thatXis some sort of hint point and you want to capture anything up to the next 4 digit year afterX?