Need help to split list of dates into array based on character length

listOfDates.txt (4.6 KB)
Please take a look at the text document.
I need to split the text doc which contain basically dates into array of dates.
Helpful tips: Consistent 16 characters (assume whitespace is consider a character?)

Snapshot:
Mon, 10 Apr 2023Thu, 06 Apr 2023Mon, 03 Apr 2023Thu, 30 Mar 2023Mon, 27 Mar 2023Thu, 23 Mar 2023Mon, 20 Mar 2023Thu, 16 Mar 2023Mon, 13 Mar 2023Thu, 09 Mar 2023Mon, 06 Mar 2023Thu, 02 Mar 2023Mon, 27 Feb 2023Thu, 23 Feb 2023Mon, 20 Feb 2023Thu, 16 Feb 2023Mon, 13 Feb 2023Thu, 09 Feb 2023Mon, 06 Feb 2023Fri, 03 Feb 2023Mon, 30 Jan 2023Thu, 26 Jan 2023Mon, 23 Jan 2023Fri, 20 Jan 2023Mon, 16 Jan 2023Thu, 12 Jan 2023Mon, 09 Jan 2023Fri, 06 Jan 2023Mon, 02 Jan 2023Thu, 29 Dec 2022Mon, 26 Dec 2022Thu, 22 Dec

to return me array of dates as such

  • Mon, 10 Apr 2023
  • Thu, 06 Apr 2023
  • Mon, 03 Apr 2023
  • and so on…

how can I go about it?

Hi,

How about the following?

arrDateStr = System.Text.RegularExpressions.Regex.Matches(strData,".{16}").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Value).ToArray()

Sample20230410-1aL.zip (3.5 KB)

Regards,

1 Like

FYI, another expression:

arrDateStr = Enumerable.Range(0,strData.Length \ 16).Select(Function(i) String.Join("",strData.Skip(i*16).Take(16))).ToArray()

Regards,

3 Likes

@ryancheeRPA

Another way of dealing this issue

image

Take a String variable, Here in image it is DatesInArray

> DatesInArray = System.Text.RegularExpressions.Regex.Matches(samplesDates, "([A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4})").Cast(Of Match)().Select(Function (m) m.Value).ToArray

It contains 31 dates
image

Hope this may help you

Thanks,
Srini

1 Like

Beautiful! It works!

1 Like

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