-4

我有一个字符串中的 Html 页面。

  <html> 
    .....
    <script>
        {
           http:\\\/\\\/cs513404v4.vk.me\\\/u3692175\\\/videos\\\/49a2e8d28c.720.mp4 
        }
        .....
    </script>
  </html>

这个html页面中有一个链接。如何搜索“720.mp4”并获取所有此链接。谢谢您的帮助。

4

1 回答 1

1

简单的正则表达式会帮助你。

您正在寻找以 http 开头并以 720.mp4 结尾的内容

示例代码:

string strRegex = @"http.*720.mp4";
RegexOptions myRegexOptions = RegexOptions.None;
Regex myRegex = new Regex(strRegex, myRegexOptions);
string strTargetString = @"<html> " + "\n" + @"    ....." + "\n" + @"    <script>" + "\n" + @"        {" + "\n" + @"           http:\\\/\\\/cs513404v4.vk.me\\\/u3692175\\\/videos\\\/49a2e8d28c.720.mp4 " + "\n" + @"        }" + "\n" + @"        ....." + "\n" + @"    </script>" + "\n" + @"  </html>";

foreach (Match myMatch in myRegex.Matches(strTargetString))
{
  if (myMatch.Success)
  {
    // Add your code here
  }
}
于 2013-08-19T09:47:04.000 回答