$re = '/http[s]?:\/(?:\/[^\/]+){1,}(?:\/[А-Яа-яёЁ\w ]+\.[a-z]{3,5}(?![\/]|[\wА-Яа-яёЁ]))/m';
$str = 'https://i.imgur.com/pO5SM73.png
https://i.imgur.com
https://i.imgur.ru/a.gdb
http://bse.sci-lib.com/article089432.html
http://megabook.ru/article/Кошка Собака.png
http://architect.academic.ru/3502/Мансарда
http://megabook.ru/article/%D0%90%D0%BD%D1%82%D0%B0%D0%B1%D0%BB%D0%B5%D0%BC%D0%B5%D0%BD%D1%82
http://bse.sci-lib.com/a_pictures/17/10/265722250.jpg
http://dic.academic.ru/dic.nsf/stroitel/4
<brbrbr> okk http://fooo-bar.com/more/than/file.exe fdfdfs http://fooo-bar.com/more/than/fil2.exe
http://a.org/ddddd.ddddd
http://a.org/ddddd.dddddв';
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