How to get specific data from middle of the sentence

Hey there,

I’m trying to pick up first date from a sentence and collect it into the variable but it occurs wrong result. First I used get text activity to get sentence “Project starts 2.3.2015 and ends 3.6.2017”.

Then I used assign activity as
FirstDate = FirstDate.split(“Project starts “,” and ends 3.6.2017”).ToString

I got System.String for a result although I wanted it as a date in a string format.

I also tried this :
FirstDate.Split({"Project starts "},System.StringSplitOptions.None).ToString and got the same result…

Do you know any better option how could I get it right? I need to use this in a loop and dates are going to change so I’m not able to know how many numbers there are.
There is a picture to give some idea what’s happening. Thank you for your help!


If MyText is the text containing the date, then to get the date as a string MyStr, assign MyStr to System.Text.RegularExpressions.Regex.Matches(MyText, "\d{1,2}\.\d{1,2}\.\d{4}")(0).ToString.

If you want to convert that to a date, then assign MyDate to Date.ParseExact(System.Text.RegularExpressions.Regex.Matches(MyText, "\d{1,2}\.\d{1,2}\.\d{4}")(0).ToString, "M.d.yyyy", System.Globalization.CultureInfo.InvariantCulture)


Great, that works!! Thanks a lot :slight_smile:

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