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

前端 未结 5 1892
無奈伤痛
無奈伤痛 2021-02-11 00:10

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 00:55

    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)

提交回复
热议问题