$re = '/(.*Request.*\[(?P<req_ip>.*)\:.*\].*GZIP)\n(.*)\n(.*)\n(.*Play.*\'(?P<watched>.*)\'.*)\n(.*User is\s(?P<who>.*)\s\(.*)\n(.*Device is(?P<device>.*)\.)\n(.*)\n(.*Completed.*\=(?P<movie_time>\d+)\&k.*\&time\=(?P<played_time>\d+)\s\(.*)/';
$str = '[2016-07-03 13:45:04,777] INFO PlayQueueInputStream - brent listening to "Firehouse/Love Of A Lifetime.MP3"
[2016-07-02 21:21:10,615] INFO TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-i] [/pub/media/mp3/Rock/TedNugent/Cat Scratch Fever/01 Cat Scratch Fever.wma] [-map] [0:0] [-b:a] [192k] [-v] [0] [-f] [mp3] [-]
[2016-07-02 19:46:57,695] INFO TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-i] [/pub/media/mp3/Rock/Kansas/01 Carry on Wayward Son.wma] [-map] [0:0] [-b:a] [192k] [-v] [0] [-f] [mp3] [-]
[2016-07-02 19:28:31,635] INFO TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-i] [/pub/media/mp3/Rock/Queen/Greatest Hits [Parlophone]/14 Flash.wma] [-map] [0:0] [-b:a] [192k] [-v] [0] [-f] [mp3] [-]
[2016-07-02 22:12:39,647] INFO TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-i] [/pub/media/mp3/Pop/Katy Perry/One of the Boys/02 I Kissed a Girl.m4a] [-ab] [192k] [-ar] [44100] [-ac] [2] [-v] [0] [-f] [mp3] [-]
[2016-06-26 11:10:29,662] INFO TranscodeInputStream - Starting transcoder: [/var/subsonic/transcode/ffmpeg] [-i] [/pub/media/mp3/Christian/The Almost/2013 - Fear Inside Our Bones/03 - I\'m Down.flac] [-ab] [192k] [-ar] [44100] [-ac] [2] [-v] [0] [-f] [mp3] [-]
[2016-07-04 19:47:41,874] INFO DownloadController - Downloading \'This is not a test (2015)/15. Like A Match (Garcia\'s Remix).mp3\' to Player 103 [caryn]
INSERT INTO MEDIA_FILE VALUES(146130,\'/pub/media/mp3/Alternative/WorldParty/Goodbye Jumbo/06 And I Fell Back Alone.flac\',\'/pub/media/mp3/Alternative\',\'MUSIC\',\'flac\',\'06 And I Fell Back Alone\',\'Goodbye Jumbo\',\'WorldParty\',\'WorldParty\',NULL,NULL,NULL,NULL,NULL,FALSE,NULL,20943444,NULL,NULL,NULL,\'/pub/media/mp3/Alternative/WorldParty/Goodbye Jumbo\',0,NULL,NULL,\'2013-05-24 16:42:12.000000000\',\'2013-05-24 16:42:12.000000000\',\'2016-07-07 20:02:08.217000000\',\'1969-12-31 18:00:00.000000000\',TRUE,4)
/*C2445758*/SET SCHEMA PUBLIC
CONNECT USER SA
DISCONNECT
Jul 06, 2016 23:40:04 [0x7fdbf063b700] DEBUG - Loading Movie \'Batman v Superman: Dawn of Justice\' XML from /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Metadata/Movies/2/2d037fa20a5177c5442ca5d6fc44c7aea0940d6.bundle/Contents/_combined/
Jul 08, 2016 02:03:55 [0x7fdbf063b700] DEBUG - Loading Artist Liquido from XML file: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Metadata/Artists/f/e4d9aa73581b1e97d433a111542ca12b5a97f29.bundle/Contents/_combined/Info.xml
Adding xxxxxxxxxxxxxxxxxxxx as token for 42 sections for jefferyblake
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - Request: [172.56.6.129:54338] GET /:/timeline?duration=6886122&key=/library/metadata/67850&playQueueItemID=2926&ratingKey=67850&state=playing&time=5286338 (13 live) TLS GZIP
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - Auth: We found auth token (xxxxxxxxxxxxxxxxxxxx), enabling token-based authentication.
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - Client [0B3645F6-539D-4428-86DB-E954F15992F9] reporting timeline state playing, progress of 5286338/6886122ms for guid=, ratingKey=67850 url=, key=/library/metadata/67850, containerKey=, metadataId=67850
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - Play progress on 67850 \'Pitch Perfect 2\' - got played 5286338 ms by account 4033586!
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - [Now] User is deliaswaz (ID: 4033586)
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - [Now] Device is iOS (Alan\'s iPhone).
Jul 03, 2016 18:51:03 [0x7fdc0b125700] DEBUG - [Now] Updated play state for /library/metadata/67850.
Jul 03, 2016 18:51:03 [0x7fdc0fbff700] DEBUG - Completed: [172.56.6.129:54338] GET /:/timeline?duration=6886122&key=/library/metadata/67850&playQueueItemID=2926&ratingKey=67850&state=playing&time=5286338 (13 live) TLS GZIP 6ms 203 bytes 200 (pipelined: 5)';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php