This is my current regex (used in parsing an iCal file):
/([^:]+)[:|(;)]([\w\W]*)/
The current output using preg_match()
is this:
//Output 1
Array
(
[0] => DTEND;TZID="Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London":20150601T073000
[1] => DTEND;TZID="Greenwich Mean Time
[2] => Dublin, Edinburgh, Lisbon, London":20150601T073000
)
I would like to amend my regex to output this (i.e. ignore a colon if it is part of a phrase surrounded by double quotes - I think I need a lookbehind and there would only ever be one colon to find as it's a separator):
//Output 2
Array
(
[0] => DTEND;TZID="Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London":20150601T073000
[1] => DTEND;TZID="Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London"
[2] => 20150601T073000
)
The semicolon in the regex is there because sometimes the colon I'm looking for might be on the next line due to multiple properties being defined (;TZID="Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London"
) so in this case I break on the semicolon. For info, the iCal file is read in one line at a time.