silkefu
(Silkefu)
May 12, 2023, 8:56am
1
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
adiijaiin
(Aditya Jain)
May 12, 2023, 9:00am
2
Hi @silkefu
Can you provide the input Sample data?
Regards,
Aditya
silkefu
(Silkefu)
May 12, 2023, 9:06am
3
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
Yoichi
(Yoichi)
May 12, 2023, 9:14am
4
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
lrtetala
(Lakshman Reddy)
May 12, 2023, 9:14am
5
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
1 Like
adiijaiin
(Aditya Jain)
May 12, 2023, 9:15am
7
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
system
(system)
Closed
May 15, 2023, 9:15am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.