Hi @FWD!
I am by no means a regex expert, but I did some Googling and found this expression, which might help:
^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
I think that the format of this will match for dates that are day/month/year, so if you’re working with US formatted dates, you’ll need to switch it around a bit. I found a way of testing it on this site. As an fyi, that’s not an official Zapier resources, just something a found with some Googling, so do check the formula for yourself before you use it.
If anyone else has any ideas on how to edit @FWD’s query to account for years that may be 2 or 4 digits, it’d be great to hear them!
Hey Danvers,
This seems to capture some date formats but not all of them. I unfortunately don’t have the know how to fix this to include the ones I need which are:
MM/DD/YYYY, M/DD,YYYY, MM/D/YYYY, M/D/YYYY, MM/DD/YY, M/DD/YY, MM/D/YY, and M/D/YY
Just a quick update, I found a good expression: ^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
That matches all formats I need, however it doesn’t seem to extract the pattern out of a wall of text. Only if the only input is the date itself. For my purposes, I need the expression to find the date in a wall of text like this:
Date to be sent: 09/05/2022
Time to be sent: 10:00AM
Can someone please help me modify this to search in the full message and not only look for the full message to match the pattern? Thanks in advance!
Hey @FWD! I’ve checked with a few folks on our end but unfortunately, we’re not super familiar/well-versed in regex expressions. So while we can’t help from the Zapier side, I will leave this thread open incase there is another community member who might be able to help!
CCing @Troy Tessalone, @MohSwellam @Moshe770 and @andywingrave here incase any of y’all have ideas to share!