$re = '/(?<=SUBH2002078568)[\s\S]+?(?=SUBF2002078568)/m';
$str = 'HMT940040324
SUBH2002078568
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568
SUBH2003001298
2003001298{1:F01BANK MBI}{2:I940MAP}{4:
2003001298:20:20210420182417
2003001298:25:2003001298
2003001298:28C:00075
2003001298:60F:C210420IDR111520964,38
2003001298:62F:C210420IDR111520964,38
2003001298-}
SUBF2003001298
SUBH2002078568 // *Added this account from the top*
2002078568{1:F01BANK MBI}{2:I940MAP}{4:
2002078568:20:20210420182417
2002078568:25:2002078568
2002078568:28C:00075
2002078568:60F:D210420IDR0,
2002078568:62F:D210420IDR0,
2002078568-}
SUBF2002078568- // End
FMT9400000004';
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