Regex for date

I am searching for for date
best regex for date to cover maximum cases/formats to get date in dd/mm/yyyy format

date can be like 26 March 21 , 19 Feb 2021,12 Feb 21,19 March 21

I remember previously matches activity had prewritten date regex a very long one that fetches date from any kind of text

Please share regex

you need the regex code to extract the date 19 March 21

I need the code that can fetch date and covers maximum date formats

\d{2}\s\w+\s\d{2,4} this is the regex code to extract the date

Hi try this:

output = System.Text.RegularExpressions.Regex.Match(your_String,"\d{1,2}\s\w{3,5}\s\d{2,4}").Value

image

Preview link: regex101: build, test, and debug regex

1 Like

Hi

A full list of your expected date formats is needed to build a robust Regex pattern.

In the meantime, try this pattern:

3 Likes

@sarathi125 Parthasarathi I see you have shared solution using LINQ

Dim oddCategories = projectsByCat.Where(Function(cat, index) index Mod 2 = 0)
Dim evenCategories = projectsByCat.Where(Function(cat, index) index Mod 2 <> 0)

same thing can I use to get the date or maximum date ?

@Sakshi_Jain ,
If you are looking for Regex to match maximum number of date patterns then check the below link. You can see lots of date format regex patterns in that and you can use a | (pipe symbol) to use all those formats in a single Regex Match.

If you need to get the second highest date then first you need to convert all the dates to a particular format and you can identify using the similar query which you have referenced from my other post.

Can i use vb.net code with invoke code activity ?

@Sakshi_Jain, Yeah we can use that

Please guide how can we do

I see you have shared solution using LINQ

Dim oddCategories = projectsByCat.Where(Function(cat, index) index Mod 2 = 0)
Dim evenCategories = projectsByCat.Where(Function(cat, index) index Mod 2 <> 0)

same thing can I use to get the date or maximum date ?