c# regex parse file in ical format and populate object with results

前端 未结 5 1952
清酒与你
清酒与你 2021-02-11 00:12

I\'m trying to parse a file that has the following format:

BEGIN:VEVENT
CREATED:20120504T163940Z
DTEND;TZID=America/Chicago:20120504T130000
DTSTAMP:20120504T1640         


        
5条回答
  •  醉话见心
    2021-02-11 01:00

    Try:

    (?[^:;]*)[:;](?[^\s]*)
    

    C# snippet:

    Regex regex = new Regex(
    @"(?[^:;]*)[:;](?[^\s]*)",
    RegexOptions.None
    );
    

    It takes a string of any character but a colon or semicolon as the key, and then anything else but whitespace as the value.

    If you want to test it or make changes, check out the regex checker I have on my blog: http://blog.stevekonves.com/2012/01/an-even-better-regex-tester/ (requires silverlight)

提交回复
热议问题