Curious to know whether can we have a regex to fetch all the forms of dates in a text and then covert all of them in a single format, “dd/mm/YYYY”?
Below are the date formats:
4 mars 20
4 Avril 2020
I do have the individual regex for the first 3 formats.
we do not need regex as datetime Parse exact can be configured to handle multiple formats.
Give me some mins I will search and share the code lines from the past
Thanks for the reply and your help!
I need to get the amounts of different form as well, currently extracting them using various regex and then combining. As you mentioned about the date, is there something we can do for amount?
Means to extract all forms of amount from a text?
Need to extract below formats of the amounts
4 022, 18
initial digit can be 1 or 2
14 413, 21
one by one, and one topic one case, so clear problem-solution pairs can be offered to others who are doing researches
the formats are configured in a dt:
so it can be externalized (less formats can be handled in comma seperated string and handled with String .Split…)
following parse is handling many formats in one statement:
DateTime.ParseExact(row(0).ToString.trim, arrFormats, cultureinfo, DateTimeStyles.None)
most of the dates are parsed:
22-MAR-2020 is not a valid date string and is confusing. So I suggest to you a further RnD:
However it is handled by a try catch and do not block the other dates:
Starter Help here:
Parsing_MultipleFormats_DTConfig.xaml (13.4 KB)
Yeah sorry for this. I’ll take topics it once at a time.
Okay, Thanks a lot @ppr for this information. It’s helpful
I’ll do work on this further.
Create an array variable and assign following values into it
DateTime.ParseExact(row(0).ToString, arr_DateFormat, new CultureInfo(“en-US”), DateTimeStyles.None).ToString(“dd-MM-yyyy”)
above method to convert date into a single format in comes through in the various format
to use above method you need to add following namespace to uipath otherwise it wont recognize culture and style info
or you can use the easiest method just
Assumption:- row(0).ToString is the value of datatable date value you get from excel
Thanks @SamanGuruge for providing the solution for the conversion task.
But I do not have the list of dates already. I need to extract the dates from a string and that string can contain date in any format mentioned above in my first post. Can you suggest anything for extract all the dates from the string?
Currently I am using different regex for the different type of dates. But can we have more generic regex to extract dates?
you have list of date pattern so that you can include in the array and parse that date pattern and your date value into Exactparse method and convert it into a single format
I will try this now.
ok let me know if you need anything from my end
Sorry, I’m afraid I didn’t get the parse stuff understood correctly.
Can you please have a look at the project attached. The one sample Input file has certain dates in all different formats. I need to extract that and then convert into a standard form.
DateExtract_Asnmnt_18.4.zip (18.4 KB)
use this one it working fine for ur all date formats
DateExtract_Asnmnt_18.4 sam.zip (20.8 KB)
Thanks a lot @SamanGuruge
that is working fine but just two small doubts
- It is extracting “12.12.45” as the original text in another sample file contains “188.8.131.52.5”
and also extracting “52 EUR 34” as the input contains “124 52 EUR 34 56 EUR”
I will have a try catch and if the error is “Input not a valid date format” than I will delete that item from Match Result. Just want to confirm, any other solution to this?
- It is not accepting the months Mai and Mars but not the other ones like, 13 Avril 2020, 9 septembre 2020. can this be added in the match regex of the code?
I have been using this regex extract this type of date : “(0[1-9]|[0-9]|3)\s(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)\s20\d\d\b”
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.