- var_dump: documentation ( source)
- preg_match: documentation ( source)
<?php
$string = "<!-- static comment-->
<a href='/dir1/dir2/DYNAMIC'>
STRING1
STRING2
</a>";
$pattern ="# comment-->\n\s*<a href...dir1.dir2..*?>\s*([\w]+)\s*([\w]+)#s";
preg_match($pattern, $string, $match);
var_dump($match[1]);