using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"BEGIN:VEVENT([\s\S](?!BEGIN:VEVENT))+?sdf[\s\S]+?END:VEVENT";
string input = @"BEGIN:VEVENT
LAST-MODIFIED:20140203T092537Z
CREATED:20140101T161157Z
DTSTART:20140220T150000Z
DTSTAMP:20140203T092537Z
DTEND:20140220T170000Z
SUMMARY:Summary of Event
UID:appointment_27140
END:VEVENT
BEGIN:VEVENT
LAST-MODIFIED:20140203T092537Z
CREATED:20140101T161157Z
DTSTART:20140221T070000Z
DTSTAMP:20140203T092537Z
DTEND:20140221T130000Z
SUMMARY:Event 2
UID:appointment_27135
LOCATION:TINF11B2
END:VEVENT
BEGIN:VEVENT
LAST-MODIFIED:20140203T092537Z
CREATED:20140101T161157Z
DTSTART:20140221T070000Z
DTSTAMP:20140203T092537Z
DTEND:20140221T130000Z
SUMMARY:asd
UID:appointment_27135
LOCATION:TINF11B2
END:VEVENT
BEGIN:VEVENT
LAST-MODIFIED:20140203T092537Z
CREATED:20140101T161157Z
DTSTART:20140221T070000Z
DTSTAMP:20140203T092537Z
DTEND:20140221T130000Z
SUMMARY:sdf
UID:appointment_27135
LOCATION:TINF11B2
END:VEVENT
BEGIN:VEVENT
LAST-MODIFIED:20140203T092537Z
CREATED:20140101T161157Z
DTSTART:20140221T070000Z
DTSTAMP:20140203T092537Z
DTEND:20140221T130000Z
SUMMARY:dfg
UID:appointment_27135
LOCATION:TINF11B2
END:VEVENT";
RegexOptions options = RegexOptions.Singleline;
Match m = Regex.Match(input, pattern, options);
Console.WriteLine("'{0}' found at index {1}", m.Value, m.Index);
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx