You are viewing limited content. For full access, please sign in.

Question

Question

Pattern matching Dates in text format: Jan 01, 2021 (for eample)

asked on August 4, 2022

Hi,

I have been working in an Atom project to build the following pattern matching RegEx to pattern match text format dates:

Jan 01, 2016

Feb 01, 2016

etc.

I have the following:

(\b\d{1,2}\D{0,3})?\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|(Nov|Dec)(?:ember)?)\D?(\d{1,2}\D?)?\D?((19[7-9]\d|20\d{2})|\d{2})

Which in theory works in Atom, but when I apply this in my WF it returns:

01,20162016 when Jan 01, 2016 is presented to it.

I'm in need of a second (or more) pair of eyes to see where I'm going wrong.

Thank you.

0 0

Replies

replied on August 4, 2022

It's the extra set of parentheses in

((19[7-9]\d|20\d{2})|\d{2})

It should work as expected if you change it to

(19[7-9]\d|20\d{2}|\d{2})
0 0
replied on August 5, 2022 Show version history

Thanks for catching that!

 

However I get 01, 2016 but not Jan 01, 2016 when I offer Jan 01, 2016 within a text string.  I thought I was picking out the month within the string, but it appears to be finding it and then just returning the text which follows it.  Have I created a non-capturing group without knowing? frown

 

UPDATE:

Stand down everyone.  I had a rouge "?" in: 

(:Jan(?:uary)?|Feb(?

 

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.