开发者

PHP - preg_match_all - iCalendar - REGEX

i need help with creating a regex for putting all values into an array!

assuming we have a huge file full of theese:

Classic iCalendar style:

so we know that each segment start with BEGIN:VEVENT and end with END:VEVENT

...
END:VEVENT 

BEGIN:VEVENT
UID:e3cafdf3-c5c7-427e-b8c3-653015e9321a
SUMMARY:Some Text Here
DESCRIPTION:Some Text Here\n555-555-555
ORGANIZER;CN=Some/Text/Here
DTSTART;TZID="Some/Text/Here":20100802T190000
DTEND;TZID="Some/Text/Here":20100802T193000
STATUS:CONFIRMED
CLASS:PUBLIC
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
TRANSP:OPAQUE
X-MICROSOFT-DISALLOW-COUNTER:TRUE
DTSTAMP:20100423T021222Z
SEQUENCE:1
END:VEVENT 

BEGIN:VEVENT
...

by using preg_match_all that i think is the best choice for doing this, what's the regex that can hold all theese values into array!?

PS: between segments there are no li开发者_开发技巧ne break this is just for example!

EDITED: just for clarification i want achieve a result like this:

        Array
        (
            [0] => Array
                (
                [0] => '
UID:e3cafdf3-c5c7-427e-b8c3-653015e9321a
SUMMARY:Some Text Here
DESCRIPTION:Some Text Here\n555-555-555
ORGANIZER;CN=Some/Text/Here
DTSTART;TZID="Some/Text/Here":20100802T190000
DTEND;TZID="Some/Text/Here":20100802T193000
STATUS:CONFIRMED
CLASS:PUBLIC
X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY
TRANSP:OPAQUE
X-MICROSOFT-DISALLOW-COUNTER:TRUE
DTSTAMP:20100423T021222Z
SEQUENCE:1
                   '
                )

            [1] => Array
                (

...
                )
    ...

        )

thank's to All for the time!

Regards Luca Filosfi


Why use regular expressions?

This sounds like a job for explode() and a little bit of cleanup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜