Finding a date inside a sentence in excel with an if statement

Hey,

So I have an excel sheet, where in column A there is a long sentence, with 3 different dates and I would like to make an if statement, where it reads the sentence first, and then if it is true it moves on to read only the last date.
So what would I need to write in the if statement?
And when I have to read the last date in the True, would I need to use the Text Left/Right method to get that specific date?
Thanks :slight_smile:

Hi @silkefu

Can you provide the input Sample data?

Regards,
Aditya

So it is this kind of way, and it just need to read it and then go in True in the statement, and then read the last date

HI,

Can you try as the following?

mc = System.Text.RegularExpressions.Regex.Matches(CurrentRow(0).ToString,"\b\d{2}/\d{2}-\d{4}\b")

Next check mc.Count>0 then extract final date using the following expression

mc(mc.Count-1).Value

Regards,

1 Like

Hi @silkefu By using regex to solve this:
(?<=er )(\d+/\d+-\d+)


Regards,

1 Like

Hi @silkefu ,

We should be able to use IsMatch() to check if there is a match in the pattern, then use Matches to Extract the Last matched data.

Regex.IsMatch(strInput,"\d{2}\/\d{2}\-\d{4}")
Regex.Matches(strInput,"\d{2}\/\d{2}\-\d{4}").Last.Value

image

1 Like

Hi @silkefu

I have used Regex to identify the date pattern:

“(\d*)/(\d*)-(\d{4})”

If there are always gonna be 3 dates You can use the following to identify: dateCollection(2).toString

If there could be 2 or 3 or more dates use the logic as given in XAML file.
Date3Extract.xaml (6.6 KB)

See the workflow if that helps.

Thanks

1 Like

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