i need to build a pattern to match a multiline code
$data[\'infos\'] = array();
foreach ($infos as $info) {
$data[\'infos\'][] = array(
If a simple pattern would be sufficient depends on how your input could look like.
$re = '~\Q$data[\'infos\'][]\E.*?\);~s';
\Q
...\E
is used to match literally (also could escape the brackets/dollar)..*?
in single line mode (s
flag) matches lazily any amount of any character.See demo at regex101 or php demo at eval.in