用于拆分html的C#正则表达式 [英] C# regular expression for splitting out html

查看:203
本文介绍了用于拆分html的C#正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我希望有人不介意给我写一个复杂的正则表达式,最好用c#来分割html文本。



基本上寻找一个数组,其中包含所有格式化标签作为数组中的字符串以及每个单独的单词。保持单词的顺序很重要



这可能是不可能的,但如果是,我可以使用一些帮助。



谢谢

Carl

Hi guys,

I'm hoping someone wouldn't mind writing me a complex regular expression, preferably in c# for splitting html text.

basically looking for an array that contains all the formatting tags as strings in the array and also every separate word. Maintaining the order of the words is important

This may not be possible but if it is i could use some assistance.

Thanks
Carl

推荐答案

不要这样做 - 它太可怕了,而且太容易打破。远远不够复杂的修复! :笑:



看看正确解析它 - 那里有一些好的,但这个会让你开始:在C#中分析HTML标签 [ ^ ]

或者:另一个使用标记处理的C#Legacy HTML Parser [ ^ ]

或者: C#中的AfterWork HTML Parser [ ^ ]

或者这个: HTML元标记解析器 [ ^ ]

取决于您的具体操作。
Don't do it - it's pretty horrible, and far, far too easy to break. And far, far to complicated to fix! :laugh:

Look at parsing it properly instead - there are some good ones out there, but this one will get you started: Parsing HTML Tags in C#[^]
Or this: Another C# Legacy HTML Parser Using Tag Processing[^]
Or this: AfterWork HTML Parser in C#[^]
Or this: HTML Meta Tag Parser[^]
Depending on what exactly you are trying to do.


这篇关于用于拆分html的C#正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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