Level 70
@untymage If it is the collection, what if you use get()->each(), then pass the regular expression inside the closure in each() method?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
This my vanilla php:
preg_match_all('~my regex pattern that capture 5 groups ~', $content, $m);
array_map(fn($l, $s, $e, $b) => [
'line' => $l,
'start' => $s,
'end' => $e,
'body' => $b
], $m[2], $m[3], $m[4], $m[5]);
Is it possible to do this in laravel collection ? I tried Str::of($content)->matchAll() but the problem is, it only return group 1 or 0 but my regex capture 5 group, even i opened an issue in github https://github.com/laravel/framework/issues/35509 he ignore without reading my issue
Please or to participate in this conversation.