3v4l.org

run code in 300+ PHP versions simultaneously
<?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]);

preferences:
36.58 ms | 402 KiB | 5 Q