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

Question

Question

Regular Expression to grab a date

asked on September 3, 2015

I'm just starting to learn expressions for pattern matching and I'm having a hard time figuring out what expression I would use to grab the year for the pattern matching section of the workflow I'm working on.

 

The token needs to grab the year from a form which is in this format mm/dd/yyyy. I just need it to grab the yyyy.

 

What's the expression for that?

0 0

Answer

SELECTED ANSWER
replied on September 3, 2015

You can use \d{4}$ as that will grab the last four digits before the end of the input.

1 0

Replies

replied on September 3, 2015

Just to be sure. When I use the testing in the pattern matching tool, it's not giving me the date. Here's a screenshot.

0 0
replied on September 3, 2015

It looks like you have a space in front of the pattern. Remove the white space before the \d{4}$

1 0
replied on September 3, 2015

Amazing you saw that! Thanks this works perfect!

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

Sign in to reply to this post.