- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
- implode: documentation ( source)
<?php
$modules = [
'node',
'system',
'my_module_library',
'my_module',
'my1_module',
'my_module_with_prefix',
];
preg_match_all('<#' . implode('[^#]+|#', $modules) . '[^#]+#>', '#' . implode('#', $modules) . '#', $matches);
var_dump($matches);