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

Question

Question

Regular Expression (regex) to grab a date in yyyy-mm-dd pattern from a longer string

asked on June 13, 2019

Example strings:

00668907-2018-6-19_

00679506_-_2018-11-16_14.45.15_-_PQuinones

I played around with the tools at https://regexr.com/ and came up with this expression:  ^.*?-([0-9-]+) which works for the first example, but I can't get anything to work with the second example string.  Can anyone provide some assistance?  The goal is to extract only the date in YYYY-MM-DD format from the Laserfiche entry name in a workflow task.

Thanks!

 

0 0

Replies

replied on June 13, 2019

Try

(\d\d\d\d\D\d\d?\D\d\d?)

 

1 0
replied on June 13, 2019 Show version history

Thank you so much for replying.  I believe I already came up with a working solution after doing some more digging around online and experimentation.  Since it had to be dynamic not only for text after the underscore, but also for single digit and double digit months and days, I came up with the following that seems to be working:

\d{4}-\d{1,2}-\d{1,2}

 

Although, in testing yours, I have found that your solution works just as well.  Thank you!

 

 

 

 

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

Sign in to reply to this post.