Solved

Extracting 4 digit year out of date using Regular Expression?

  • 24 April 2019
  • 3 replies
  • 223 views

Badge +6

Regular Expression is bewildering.  I know dozens of programming languages at a basic-intermediate level and this one throws me for a loop!  Yes I have seen all the documentation and did Google searches but I just don't get the logic. 

 

I have a workflow that I did not build and this Regular Expression pattern is not coming through like it is on the original list (rebuilding it).  Looks like the date format is even completely diffierent than the new one. 

 

All I need is the year from the date... In this case, 2019.

Variable holding the date contains: 4/23/2019 3:42:11 PM

 

icon

Best answer by nico 24 April 2019, 09:27

View original

3 replies

Userlevel 4
Badge +10

Hi,

you can use this regex:

(d{4})

It say : I want the 4 consecutive digit, and in a date, there is no other 4 digit consecutive thant the year

Badge +6
It took out the year but left me with everything else... This was my output: 4/24/ 8:29:48 AM
Badge +17

Here is a video walking through how to apply the regex that @nico provided. It does work and you can import the workflow if needed.


 


Reply