如何提取< strong>之间的字符串标签使用C#? [英] How can I extract a string between <strong> tags usings C#?

查看:145
本文介绍了如何提取< strong>之间的字符串标签使用C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有以下字符串:

"Unneeded text <strong>Needed Text</strong> More unneeded text"

如何仅提取 需要的文本?我猜想Regex可能是最简单的方法,但对我来说Regex仍然像象形文字。

How can I extract only the "Needed Text"? I'm guessing Regex is likely the simplest way but Regex still looks like hieroglyphics to me.

推荐答案

Regex regex = new Regex("<strong>(.*)</strong>");
  var v = regex.Match("Unneeded text <strong>Needed Text</strong> More unneeded text");
  string s = v.Groups[1].ToString();

这篇关于如何提取&lt; strong&gt;之间的字符串标签使用C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆