1.正表达式 : (?<=<SPAN>)\S+?(?=</SPAN>)2.直接截取字符: string s = "<SPAN>CSDN社区</SPAN>"; string Result = s.Substring("<SPAN>".Length , s.Length - "<SPAN>".Length - "</SPAN>".Length );
Regex reg = new Regex(@"(?i)(?<=<span.*?id=""s1"".*?>)[^<]+(?=</span>)"); MatchCollection mc = reg.Matches(""); foreach (Match m in mc) { Console.WriteLine(m.Groups[0].ToString() ); }
(?<=<SPAN>)\S+?(?=</SPAN>)2.直接截取字符: string s = "<SPAN>CSDN社区</SPAN>";
string Result = s.Substring("<SPAN>".Length
, s.Length - "<SPAN>".Length - "</SPAN>".Length
);
MatchCollection mc = reg.Matches("");
foreach (Match m in mc)
{
Console.WriteLine(m.Groups[0].ToString() );
}