为您的 ASP.NET 版本查找主题 URL 重写。然后,从字符串:
www.example.com/news/business/Royal baby - 凯特生下男孩-201306251551"
您可以使用正则表达式,例如:(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})
。每个组代表您需要的信息部分。
祝你好运。
使用网站http://regexhero.net/tester/作为助手。
string strInputstring = @"www.example.com/news/business/Royal baby - Kate gives birth to boy-201306251551";
string strRegex = @"(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})";
RegexOptions myRegexOptions = RegexOptions.None;
Regex myRegex = new Regex(strRegex, myRegexOptions);
foreach (Match myMatch in myRegex.Matches(strInputstring))
{
if (myMatch.Success)
{
//myMatch.Groups[0].Value <- contains 2013.
//myMatch.Groups[1].Value <- contains 06
//myMatch.Groups[2].Value <- contains 25
//myMatch.Groups[3].Value <- contains 15
//myMatch.Groups[4].Value <- contains 51
}
}