- var_dump: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$subject = "
XYZ99
Some text XYZ99.
XYZ13
Some text XYZ33 and some text XYZ13.
XYZ45
";
var_dump(
preg_match_all('/^XYZ\d{2}$/m', $subject, $matches),
$matches
);