.*?)(\', episode=\')(?.*?)(\', guid=\')(?.*?)(\', action=)(?.*?)(, timestamp=)(?.*?)(, started=)(?.*?)(, position=)(?.*?)(, total=)(?.*?)}]*/', '/EpisodeAction{(podcast=\')(?.*?)(\', episode=\')(?.*?)(\', action=)(?.*?)(, timestamp=)(?.*?)(, started=)(?.*?)(, position=)(?.*?)(, total=)(?.*?)}]*/', ]; $episodeActions = []; $episodeActionStrings = explode(self::EPISODEACTION_IDENTIFIER, $episodeActionsString); array_shift($episodeActionStrings); foreach ($episodeActionStrings as $episodeActionString) { foreach ($patterns as $pattern) { preg_match( $pattern, self::EPISODEACTION_IDENTIFIER . $episodeActionString, $matches ); if ($matches["action"] !== null) { $episodeActions[] = new EpisodeAction( $matches["podcast"], $matches["episode"], $matches["action"], $matches["timestamp"], (int)$matches["started"], (int)$matches["position"], (int)$matches["total"], $matches["guid"] ?? null, null, ); break; } } } return $episodeActions; } }