private List<string> getURLFromContent(string content)
{
string regexStr = @"(http|ftp|https):\/\/[\w]+(.[\w]+)([\w\-\.,@?・^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])";
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(content, regexStr, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
List<string> urlStr = new List<string>();
for (int i = 0; i < mc.Count; i++)
{
if(!urlStr.Contains(mc[i].ToString()))
{
urlStr.Add(mc[i].ToString());
}
}
return urlStr;
}
获取字符串中含有超连接内容
最新推荐文章于 2022-06-01 16:05:03 发布