$re = '/(?<![src|href]\=\"(\n*|\s*)?)((?:https?):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])/i';
$str = 'http://www.naver.com
http://www.google.com
http://www.google.com
http://www.naver.com
https://www.naver.com
www.naver.com
http://naver.com
www.naver.com
<img style="vertical-align: top;" alt="" src=" https://www.kita.net/mailclub/DailyTradeNews/images/gk_top_banner_191111.jpg" border="0">
<a target="_blank" href="https://www.kita.net/asocGuidance/notice/noticeDetail.do?pageIndex=1&nIndex=1792315&indexArray=&sortArray=&searchReqType=detail&searchStartDate=&searchEndDate=&searchCommCode1=&searchCondition=TITLE&searchKeyword=">
<a target="_blank" href=" https://www.kita.net/asocGuidance/notice/noticeDetail.do?pageIndex=1&nIndex=1792315&indexArray=&sortArray=&searchReqType=detail&searchStartDate=&searchEndDate=&searchCommCode1=&searchCondition=TITLE&searchKeyword=">
<a target="_blank" href="
https://www.kita.net/asocGuidance/notice/noticeDetail.do?pageIndex=1&nIndex=1792315&indexArray=&sortArray=&searchReqType=detail&searchStartDate=&searchEndDate=&searchCommCode1=&searchCondition=TITLE&searchKeyword=">
<a target="_blank" href= "
https://www.kita.net/asocGuidance/notice/noticeDetail.do?pageIndex=1&nIndex=1792315&indexArray=&sortArray=&searchReqType=detail&searchStartDate=&searchEndDate=&searchCommCode1=&searchCondition=TITLE&searchKeyword=">
(?<!\\=\\"(\\n|\\s).?)((?:https?):\\/\\/[\\-A-Z0-9+\\u0026\\u2019@#\\/%?=()~_|!:,.;]*[\\-A-Z0-9+\\u0026@#\\/%=~()_|])
(^|[\\s\\n]|<[A-Za-z]*\\/?>)((?:https?|ftp):\\/\\/[\\-A-Z0-9+\\u0026\\u2019@#\\/%?=()~_|!:,.;]*[\\-A-Z0-9+\\u0026@#\\/%=~()_|])
//최종
(?<![src|href]\\=\\"(\\n*|\\s*)?)((?:https?):\\/\\/[\\-A-Z0-9+\\u0026\\u2019@#\\/%?=()~_|!:,.;]*[\\-A-Z0-9+\\u0026@#\\/%=~()_|])';
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