RePost for identifying date in the string

Hello
I would like to know my robot will know the date contain in the string of “Dates found in documents might be in many different forms 03 September 2019.” And date can be in any format, so please help me in this case as I am new in uipath.
Thank you

Hi @James90

You have to use Regex expressions to get the date from the string.
Please look in the forum for the sample regex expressions to extract the date from a string.

Regards,
Karthik Byggari

1 Like

I didn’t get any ideas in it. Please can you help me.
Thank you

Hi @James90

As @KarthikByggari mentioned, use regular expressions to get the date from the string.
But first, you need to know what formats your date can be in. Once you know, create a regex which can extract any date that’s in the required format/formats.

Considering a few date formats, here is what I came up with:

“(\d{1,2}(st|nd|rd|th)? [a-zA-Z]+(,?) \d{4})|(\d{1,2}(-|.|/)\d{1,2}(-|.|/)(\d{4}|\d{2}))|((\d{4}|\d{2})(-|.|/)\d{1,2}(-|.|/)\d{1,2})|([a-zA-Z]+ \d{1,2}(st|nd|rd|th)?(,?) \d{4})”

image

Try this and let me know if it works for you.

~Sid

5 Likes

Hi @siddharth
I have tried like this but it didn’t worked.

  1. Str= “Dates found in documents might be in many different forms e.g. 03 September 2019 3 September 2019”
  2. DateToBeSearch= DateTime.ParseExact( test, “(\d{1,2}(st|nd|rd|th)? [a-zA-Z]+(,?) \d{4})|(\d{1,2}(-|.|/)\d{1,2}(-|.|/)(\d{4}|\d{2}))|((\d{4}|\d{2})(-|.|/)\d{1,2}(-|.|/)\d{1,2})|([a-zA-Z]+ \d{1,2}(st|nd|rd|th)?(,?) \d{4})” , System.Globalization.CultureInfo.InvariantCulture)
  3. DateToBeSearch.tostring in message box

That is not the right way to use regex or DateTime.ParseExact() method.

Use the “matches” activity or the matches() method for this. Once you have the date/dates as string values, then convert them to date time objects.

1 Like

Hi @siddharth
It worked but I can get only one date, how can I get the dates if string contain more the one.
Thank you

If you’re using the matches activity and your input has multiple dates, it will return them ALL (as an iEnumerable collection of “match” objects), provided they are in the formats the regex has been written for.

Hi @siddharth
This my work flow please correct my workflow I didn’t get all the date. ![da|690x286]

@James90 Please attach your project folder here. Someone, if not me, will look into this.

1 Like

Hi @siddharth
Identify Date.xaml (7.9 KB)
Please correct it.