regex help to parse data - how to get all the text in between two points

98 Views Asked by At

I've seen so many of these pages and received so much help over the years. First time askign a question.

Basically, I use automation tools such as Integromat/Make/Zapier.

I have a csv file with a lot of data for a self-made booking system.

For the automation system to work, I will need to parse the data into "chunks" that I can map and add the proper functionality to.

The text looks as follows (but much longer of course):

BEGIN:VEVENT DTSTAMP:20220301T023567Z UID: xxx DTSTART;TZID=Asia/Tokyo:20210630T110000 DTEND;TZID=Asia/Tokyo:20210630T160000 DESCRIPTION:\n--------\n同日入替 : false\n前回ゲスト数 : 1\n次 SUMMARY: xxxxx (xxx / xxx xxx END:VEVENT BEGIN:VEVENT DTSTAMP:20221105T072143Z UID: xxx DTSTART;TZID=Asia/Tokyo:20210501T110000 DTEND;TZID=Asia/Tokyo:20210701T160000 DESCRIPTION:\n--------\n同日入替 : false\n前回ゲスト数 : 1\n次 SUMMARY: xxx (xxx / xxx xxx) END:VEVENT BEGIN:VEVENT DTSTAMP:20220905T023143Z UID: xxx DTSTART;TZID=Asia/Tokyo:20220227T110000 DTEND;TZID=Asia/Tokyo:20220227T160000 DESCRIPTION:\n--------\n同日入替 : true\n前回ゲスト数 : 2\n次回 SUMMARY:★ xxx (xxx / xxx xxx) END:VEVENT

I need the parts that need to be together as parts as: BEGIN:VEVENT DTSTAMP:20220301T023567Z UID: xxx DTSTART;TZID=Asia/Tokyo:20210630T110000 DTEND;TZID=Asia/Tokyo:20210630T160000 DESCRIPTION:\n--------\n同日入替 : false\n前回ゲスト数 : 1\n次 SUMMARY: xxxxx (xxx / xxx xxx END:VEVENT

BEGIN:VEVENT DTSTAMP:20221105T072143Z UID: xxx DTSTART;TZID=Asia/Tokyo:20210501T110000 DTEND;TZID=Asia/Tokyo:20210701T160000 DESCRIPTION:\n--------\n同日入替 : false\n前回ゲスト数 : 1\n次 SUMMARY: xxx (xxx / xxx xxx) END:VEVENT

BEGIN:VEVENT DTSTAMP:20220905T023143Z UID: xxx DTSTART;TZID=Asia/Tokyo:20220227T110000 DTEND;TZID=Asia/Tokyo:20220227T160000 DESCRIPTION:\n--------\n同日入替 : true\n前回ゲスト数 : 2\n次回 SUMMARY:★ xxx (xxx / xxx xxx) END:VEVENT


Meaning that everything in between two specific points, starting with "BEGIN:VEVENT" and ending with "END:VEVENT" needs to be separated.

I have been trying to learn regex but as I can see many others are saying online, its not the most welcoming thing ever .. Im struggling hard.

1

There are 1 best solutions below

2
Tim Biegeleisen On

You may try matching on the following pattern:

BEGIN:VEVENT.*?END:VEVENT

Demo

The above regex should be run in dot all mode (with the /s flag) so that .* can match across all lines in each event.