Extract date from string (data format is not specific)

i want to extract date from a string.
the date format is not fixed it could be mm/dd/yyy or dd-mmm-yy

@Krutika_Kotkar You need to try to parse it to the Required date Formats and Then Convert it to That Format if it is Successful, Also is the Data in Excel Format?

but it’s hidden in a string and i have to use regex to extract it from the string

@Krutika_Kotkar Ok :sweat_smile: Can you Show us the input string to Extract Date

use regex to extract date from your string

agreed but if the date in the string is of multiple format ex dd-mm-yy and dd-mmm-yy
then in one single regex can we extract?

@Krutika_Kotkar We can give it a Try :sweat_smile: I think it’s Possible

14-01-20 and 14-001-20 ?? like this?

14-02-1996 or 14-FEB-96

1 Like

okay gemme a minute

this will match
1-2-1996
01-02-96
1-FEB-96
01-FEB-1996
even if it has single digit its going to give you expected output

chech this regex \d{1,2}.(\d{1,2}|[A-Z\s\S]+).\d{1,5}

cheers @Krutika_Kotkar

@Krutika_Kotkar regex101: build, test, and debug regex
Check this link

Hi
usually date can come in any format, as here date is set as input, we need to ensure that we are getting the date in a fixed format atleast between two or three format to tthe maximum, only then we can validate the dateformat even with TryParse
so i would suggest to get the date input in a standard format…is that possible
Cheers @Krutika_Kotkar

[A-z0-9]{1,4}/([A-z0-9]*){1,4}/[A-z0-9]{1,4}
tried this
2020/01/Feb
Feb/14/1996
08/FEB/20
20/01/2020

it’s working for these dates

any correction ?

i think it looks good
Great,if its working fine then not a problem

i used DOT to replace special Characters thats it
you can use it instead of hardcoding it

(\d*\w*/\d*\w*/\d*\w*) Can you Check with this and just see how efficient it is :sweat_smile:

didn’t help

1 Like

yes thanks (Y)

1 Like