#region 过滤p /p代码
/// <summary>
/// 过滤p /p代码
/// </summary>
/// <param name="html">参数传入</param>
/// <returns></returns>
public static string InputStr(string html)
{
html = html.Replace(@"<p>", "");
html = html.Replace(@"</p>", "");
return html;
}
#endregion
参考这个
/// <summary>
/// 过滤p /p代码
/// </summary>
/// <param name="html">参数传入</param>
/// <returns></returns>
public static string InputStr(string html)
{
html = html.Replace(@"<p>", "");
html = html.Replace(@"</p>", "");
return html;
}
#endregion
参考这个
String str = "<font>中国 <标题>上海 </font> ";
str=str.Substring(str.IndexOf(">") + 1, str.LastIndexOf("<") - str.IndexOf(">") - 1);
樓主直接讀網頁源碼... 網頁源碼里面 "<标题>" 存的并不是 尖括號的... ... 是"& lt;" , "& gt;"
所以你匹配尖括号是OK的
string input = "<font>中国 <标题>上海 </font>";
Regex re = new Regex("(?is)(?<=<font>).*?(?=</font>)");
Console.WriteLine(re.Match(input).Value);
除了 正则表达式 还有什么更好的办法吗?
最好是用 webBrowser 我不知道怎么用 webBrowser
str = str.Substring(str.IndexOf(">") + 1, str.LastIndexOf(" <") - str.IndexOf(">") - 1);这一种不错