您应该考虑在后面的代码(.cs 或 .vb)中实现这一点。我建议使用“正则表达式”来解析 URL 字符串以获得您想要的结果。有许多带有快速 Bing 或 Google 搜索的正则表达式示例。
C# 中的简单示例:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions; //needed
namespace SplitingStrings
{
class Program
{
static void Main(string[] args)
{
string input = "http://www.yo.com/stuff/you/donot/want";
string pattern = "(.com/)"; // Split on .com/
string[] substrings = Regex.Split(input, pattern);
foreach (string match in substrings)
{
Console.WriteLine("'{0}'", match);
}
Console.WriteLine(substrings[0] + substrings[1]); //this is what you want
Console.ReadKey(true);
// The method writes the following to the console:
// 'http://www.yo'
// '.com/'
// 'stuff/you/donot/want'
// http://www.yo.com/
}
}
}
资料来源:MSDN