您好,我正在尝试为windows phone创建一个小webapp。 它拉下一个wepage并将源代码保存在一个文本块中,我想要做的是让应用程序读取该文本块并确定是否包含设置值=“http://test.com”如果它确实需要它提取完整网址。查找字符串是否包含值,然后提取
到目前为止,我有什么是
string stringToCheck = "http://test.com";
string stringhtml = invisiBlockHtml.Text;
if (stringhtml.Contains(stringToCheck))
{
// StreamReader sr = new StreamReader(stringhtml);
// here i was hoping there was some way for StreamReader or another function to read the string and then pull out the full url
webBrowser1.Navigate(new Uri("found Url", UriKind.Absolute)); }
else
{
webBrowser1.Navigate(new Uri("http://dontcontain.com", UriKind.Absolute));
}`
希望这是有道理的,我只有最近才开始编程。 感谢
看看正则表达式的http:/ /www.dotnetperls.com/regex-match – Jonesopolis
你不能那样做。我猜stringHtml可以是任何包含url的文本出现在任何地方。所以即使是正则表达式在这种情况下也无济于事。 – cissharp