正则表达式跳过协议url
答
使用这个表达式(?<=://).+
或
使用这个表达式://(.+)
没有回顾后,值[1]
答
试着用以下的正则表达式:在regexGroup
^[a-z]+://(.*)$
string input = "http://www.google.com/search";
Match match = Regex.Match(input, @"^[a-z]+://(.*)$", RegexOptions.IgnoreCase);
if (match.Success)
{
string url = match.Groups[1].Value;
}
答
你可以使用简单替换
string url = "http://url.com";
if(url.Contains("http://")){
url = url.Replace("http://","");
}
else if(url.Contains("https://")){
url = url.Replace("https://","");
}
或
url = Regex.Replace(url,@"[a-z]+://","");
THX,该诀窍。 – fsl 2013-04-05 10:50:05
net.tcp:// localhost:808 – 2013-04-05 10:51:09
'^ [az。] +://(。*)$' – hsz 2013-04-05 10:51:54