How to split the Date range from a different formats of strings?

Hi, I am receiving multiple date formats from the document like either a single date or a date range… I would like to get the from date and to date from a string. Challenge is, i may get the string in different date formats and also sometimes TO date might not come in the string as well. how to get this. below are some possible scenarios

  1. 05/05/2020
  2. 05/05/2020 - 05/05/2021
  3. 05-05-2020
  4. 05-05-2020 - 05-05-2021
  5. 05-05-2020 to 05-05-2021
  6. 05/05/2020 through 05/05/2021.

From the above example, my output would be just 2 values (if its date range), same code should work to get the single values also (like example 1). For example 1 - it should retrieve only FromDt : 05/05/2020

  1. FromDt : 05/05/2020
  2. ToDt : 05/05/2021

Suggestions plz.

@Pradeep.Robot - Assuming this is not multiline string…This patttern covers all the provided scenario, I have tested them individually…


You have to take the group(1) and Group(5) outputs for you From and To dates…

OR more simpler version…where you have take group(1) and group(3) outputs…



Please try and let me know…

@Pradeep.Robot - here you go…
Regex_Pradeep.xaml (7.3 KB)

Hope this helps…

1 Like

Thanks much Prasath, yes! this helps a lot.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.