Let's say I have the following log file (with line endings):
[xxx] test test[xxx]foobar
more data
[xxx] more data
[xxx] other data []:foo bar
more data here
[xxx] 1234
I would like to retrieve all parts starting with [xxx] up until the next occurrence of [xxx], so the result would become (\n indicating the newline here):
$result = [
'[xxx] test test[xxx]foobar \n more data',
'[xxx] more data',
'[xxx] other data []:foo bar \n more data here',
'[xxx] 1234'
]
I came up with the regex /(\[xxx\] .*)/g but it fails to match the cases where there are multiple lines per log entry. I've tried variations like /(\[xxx\] [\s.]*)/g but to no avail.
I feel like I'm missing something obvious here. What modifiers or other syntax should I use?