views:

43

answers:

1

Hi All guys! ;-)

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 line 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

+1  A: 

Why use regular expressions?

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

timdev
you think i can explode 2MB of theese segments!? before explode i want put each segment into array! or i'm doing it in the wrong way!?
aSeptik
Exploding is faster than regex, so if you're worried about size and performance, `explode` is the way to go. And given that the format is quite simple, it's probably enough.
Max Shawabkeh
Yes you are right buddy! ;-) this is quite simple! probably enough then i have thinked! ;-) sometimes happen! that i ask for simply problems! doh! %-) thanks!
aSeptik