Extract date from string , the date format is not specific

Hey , i have an issue with extracting date from a string which date format is not specific it may be
dd/MM/yyyy or dd/MM/yy or dd\MM\yyyy or dd\MM\yy or dd-MM-yyyy or dd-MM-yy or dd.MM.yyyy or dd.MM.yyyy

I used some regex expressions but doesn’t work.

Any help please?

I am not sure if it is the best solution but this is what I did in past.

Create regex for dd/MM/yyyy
Check if match found
if yes then convert the string to date and save it in a date variable.
if no match found then check regex for dd/MM/yy… and so on…

This will become a huge nested if else but works perfectly if the format is unknown. In my case, I was dealing with 4 formats.

Hello @Deep_HML

You can use Format value activity to change the format.


Hi @Deep_HML ,

Maybe we could try using the Regex Expression in the below way :



Debug Panel :

Expression :


Hi @Deep_HML,

Please try this regex pattern.


Here is the screenshot.


Shortening down @supermanPunch Approach with the dot as any char as seperator:

Or with some more restrictions to the delimeter:

When later a parsing into DateTime is needed we can handle all formats in one go:


Assing Activity
arrFormats | DataType: String() String Array =


Assign Activity:
myDateTime =

DateTime.ParseExact(YourSingleDateString, arrFormats, CultureInfo.InvariantCulture, DateTimeStyles.None)

I Tried this expression, but it does not return the date i want

here is the text i work on and the expression Split(Text,“\b(\d{2}[/\-.]){2}\d{2,4}\b”)(1) return only 01\ from the date 31\01\22

Hello Omer, i tried your solution on this text

but the expression Split(“(\d{1,2}/\d{1,2}/\d{2,4})|(\d{1,2}\d{1,2}\d{2,4})|(\d{1,2}-\d{1,2}-\d{2,4})|(\d{1,2}.\d{1,2}.\d{2,4})”)(1) return 0709099321 not the date

Hello supermanPunch i tried your solution on this text

but the expression Regex.Split(yourStringVar,“\d{2}.\d{2}.\d{4}|\d{2}.\d{2}.\d{2}”)(1)
return 909 and not the date

we are using the Match method and not a split

For regex learning also have a look here:

1 Like

we had shown

  • a generic pattern for regex match the different date strings
  • the usage of regex.match along with pattern
  • an approach to parse the string into a datetime handling many format patterns in one go

what is the motivation to use the split? maybe you can share some implementation details so we can better understand why this by us not mentioned is tried.

Can i know how to use this match expression whithin a if activity ?

refer to the cheat sheet linked above maybe a regex.IsMatch is what you are searching
also we do have the success property

1 Like

The success property works well withing if activity , i need also to extract the date thats matchs the expression and stock it into a string value is it possible ? Can i use split ?

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