Grouping of Strings

How can i pick all details between Start Of Semester and End of Semester. My input is as below

HarareInstitute

Student Report

Harare

Start of Semester: 2020-07-04

2020-07-05 07:01 001 HIT123 Tapiwa Makamure 0.00 200 2000

2020-07-05 07:01 002 HIT123 Tindo Tapera 0.00 200 2000

End Of Semester: 2021-01-10

Start of Semester: 2021-04-04

2021-07-05 07:01 001 HIT123 TGracious Chin 0.00 200 2000

2021-07-05 07:01 002 HIT123 Tindo Tera 0.00 200 2000

2021-07-05 07:01 001 HIT123 TGras Chin 0.00 200 2000

2021-07-05 07:01 002 HIT123 Tihhndo Toooera 0.00 200 2000

End Of Semester: 2021-01-10

End of Report

The result should be

*Start of Semester: 2020-07-04 *
2020-07-05 07:01 001 HIT123 Tapiwa Makamure 0.00 200 2000
2020-07-05 07:01 002 HIT123 Tindo Tapera 0.00 200 2000
End Of Semester: 2021-01-10

AND

*Start of Semester: 2021-04-04 *
2021-07-05 07:01 001 HIT123 TGracious Chin 0.00 200 2000
2021-07-05 07:01 002 HIT123 Tindo Tera 0.00 200 2000
2021-07-05 07:01 001 HIT123 TGras Chin 0.00 200 2000
2021-07-05 07:01 002 HIT123 Tihhndo Toooera 0.00 200 2000
End Of Semester: 2021-01-10

1 Like

Hi @Tapiwa,

Please, take a look at the attached possible solution.
Main.xaml (9.2 KB)

If this solves your problem and you agree, kindly mark the post that helped you the most as solution to close this topic.

If you need extra help and/or have any questions, please let me know :slight_smile:

Thanks!

Hi,

The following sample helps you.

mc = System.Text.RegularExpressions.Regex.Matches(yourString,"Start of Semester[\s\S]*?End Of Semester.*")

Sample20220728-2.zip (2.6 KB)

Regards,

1 Like

Hi @Tapiwa

(I will throw in my solution also :sweat_smile:)

You can use Regex to Achieve this :slight_smile:

I have developed a Regex pattern that doesn’t matter on the number of students in the text.
Red - Sample text
Orange - Each captured result.
Main.xaml (6.6 KB)

Here is a link to the Regex Pattern which you can review/preview.

You can learn Regex using my Regex MegaPost

Hopefully this helps you :blush:

Cheers

Steve