3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = " http://www.url1.com/ = ' http://www.url2.com/ 'http://www.url3.com/ <a href='http://www.url4.com/'>Testing1</a> <img src = 'https://url5.com'>Testing2</a>"; $url_pregex = 'https?://[-a-zA-Z()0-9@:%_+.~#?&;//=]+'; $pregex = "\\s*=\\s*['\"]?\\s*$url_pregex|($url_pregex)"; preg_match_all('`' . $pregex . '`i', $html, $matches); echo "Matches<br><pre>"; var_export(array_values(array_filter($matches[1]))); echo "</pre>";
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Matches<br><pre>array ( 0 => 'http://www.url1.com/', 1 => 'http://www.url3.com/', )</pre>

preferences:
44.22 ms | 402 KiB | 62 Q