re = /BEGIN:VEVENT.*?END:VEVENT/m
str = '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'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html