正则表达式在标签C#之间查找文本
发布时间:2020-12-14 02:30:01 所属栏目:百科 来源:网络整理
导读:我想剥离html标签,只返回标签之间的文本.这是我目前正在使用的. string regularExpressionPattern1 = @"td(.*?)/td";Regex regex = new Regex(regularExpressionPattern1,RegexOptions.Singleline);MatchCollection collection = regex.Matches(value.ToStr
我想剥离html标签,只返回标签之间的文本.这是我目前正在使用的.
string regularExpressionPattern1 = @"<td(.*?)</td>"; Regex regex = new Regex(regularExpressionPattern1,RegexOptions.Singleline); MatchCollection collection = regex.Matches(value.ToString()); 我目前得到< td> 13< / td> ;,我只想要13. 谢谢,
您需要获得不属于该组的组值.
试试这个 Match m = collection[0]; var stripped = m.Groups[1].Value; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |