Here's what I have:
=regexextract(A1,"(\d /\d /\d ){3}")
This will return the first date string:
REGEXEXTRACT(A:A,"(\d /\d /\d ){1}")
But this returns N/A:
REGEXEXTRACT(A:A,"(\d /\d /\d ){3}")
Goal: regexextract regex to return nth date string matching the format (1 or 2 digit)/(1 or 2 digit)/(2 digit). There are multiple char(10) breaks in the string as depicted in example string:
A 1234 Text Text 123-456-7890 Fri 1/14/22 9:00 AM, 12:00 PM Tue 10/18/22 10:30 AM, 4:30 PM, A 2506 Text Text 123-456-7890 Tue 11/1/22 9:00 AM, 4:30 PM Wed 1/19/22 9:00 AM, 4:30 PM
So for this example I'd like to be able to return 1/14/22 or 10/18/22 or 11/1/22 or 1/19/22 by selecting nth value i.e. 1,2,3, or 4. If the 3-letter abbreviated day of the week e.g. "Wed" could also be returned as shown in the example ahead of the date result, that regex would be additionally helpful. Thank you for reading and in advance for any help. I am sorry but it appears the char(10) breaks are not being shown after I posted the question - I am not sure how to fix that. There is a char(10) break immediately preceding the abbreviated weekday and after the sought date result, e.g. before and after "Fri 1/14/22".
CodePudding user response:
According to the text you have provided, and if you have 4 dates within the text, with or without car(10), try
=regexextract(A1,"([A-Z][a-z]{2} [0-9]{1,2}/[0-9]{1,2}/[0-9]{2}).*([A-Z][a-z]{2} [0-9]{1,2}/[0-9]{1,2}/[0-9]{2}).*([A-Z][a-z]{2} [0-9]{1,2}/[0-9]{1,2}/[0-9]{2}).*([A-Z][a-z]{2} [0-9]{1,2}/[0-9]{1,2}/[0-9]{2})")
CodePudding user response:
I figured it out, replacing the number in the bracket returns the nth match of the date string:
=REGEXEXTRACT(A1,"(?:.*?(\d /\d /\d )){3}")
Now I'll worry about adding the abbreviated day. Thanks to all for your contributions.
...and with the abbreviated day:
=REGEXEXTRACT(A1,"(?:.*?([A-Z][a-z]{2} \d /\d /\d )){3}")
Thanks again to all who contributed responses in helping to find a solution.