using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<![src|href]\=\""(\n*|\s*)?)((?:https?):\/\/[\-A-Z0-9+\u0026\u2019@#\/%?=()~_|!:,.;]*[\-A-Z0-9+\u0026@#\/%=~()_|])";
string input = @"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@#\/%=~()_|])";
RegexOptions options = RegexOptions.IgnoreCase;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx