首页 新闻 搜索 专区 学院

C#使用正则表达式解析下列表格html标签中td标签类名是"hebrew2"的内容 ,请问怎么做?

0
悬赏园豆:20 [已解决问题] 解决于 2014-12-18 13:39
Str Translit Hebrew English Morph
559 [e] way-yō-mer וַיֹּ֣אמֶר And said Verb
430 [e] ’ĕ-lō-hîm, אֱלֹהִ֗ים God Noun
1876 [e] taḏ-šê תַּֽדְשֵׁ֤א let bring forth Verb
776 [e] hā-’ā-reṣ הָאָ֙רֶץ֙ the earth Noun
1877 [e] de-še, דֶּ֔שֶׁא grass Noun
6212 [e] ‘ê-śeḇ עֵ֚שֶׂב the herb Noun
2232 [e] maz-rî-a‘ מַזְרִ֣יעַ yielding Verb
2233 [e] ze-ra‘, זֶ֔רַע seed Noun
6086 [e] ‘êṣ עֵ֣ץ tree Noun
6529 [e] pə-rî פְּרִ֞י the fruit Noun
6213 [e] ‘ō-śeh עֹ֤שֶׂה yielding Verb
6529 [e] pə-rî פְּרִי֙ fruit Noun
4327 [e] lə-mî-nōw, לְמִינ֔וֹ according to their kind Noun
834 [e] ’ă-šer אֲשֶׁ֥ר whose Prt
2233 [e] zar-‘ōw- זַרְעוֹ־ seed Noun
  ḇōw ב֖וֹ in itself Prep
5921 [e] ‘al- עַל־ [is] on Prep
776 [e] hā-’ā-reṣ; הָאָ֑רֶץ the earth Noun
1961 [e] way-hî- וַֽיְהִי־ and it was Verb
3651 [e] ḵên. כֵֽן׃ so Adj
哈勒斌程序员的主页 哈勒斌程序员 | 初学一级 | 园豆:150
提问于:2014-12-18 11:29
< >
分享
最佳答案
0
string htmlSource =
                "asdf<td class=\"hebrew2\" valign=\"top\">123</td>asdf<td class=\"hebrew2\" valign=\"top\">看老婆</td><td class=\"hebrew2\" valign=\"top\">456</td>asdf<td class=\"hebrew2\" valign=\"top\">上课了</td>asdfsadf";

            Regex reg = new Regex("<td\\s+class=\"hebrew2\".*?>(?<val>.*?)</td>");
            var ms = reg.Matches(htmlSource);
            for (int i = 0; i < ms.Count; i++)
            {
                Console.WriteLine(ms[i].Groups["val"].Value);
            }
收获园豆:10
PandaIT | 菜鸟二级 |园豆:333 | 2014-12-18 11:47

推荐一个解析HTML的利器,AngleSharp。

http://www.pandait.me/dotNet/AngleSharp

PandaIT | 园豆:333 (菜鸟二级) | 2014-12-18 11:48
其他回答(1)
0

<td[^<]*class="hebrew2"[^<]*>.*?</td>

收获园豆:10
Yu | 园豆:12944 (专家六级) | 2014-12-18 13:37
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册