zoukankan
html css js c++ java
提取HTML代码中文字的C#函数
/**/
///
<summary>
///
去除HTML标记
///
</summary>
///
<param name="strHtml">
包括HTML的源码
</param>
///
<returns>
已经去除后的文字
</returns>
public
static
string
StripHTML(
string
strHtml)
{
string
[] aryReg
=
{
@"
<script[^>]*?>.*?</script>
"
,
@"
<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>
"
,
@"
([\r\n])[\s]+
"
,
@"
&(quot|#34);
"
,
@"
&(amp|#38);
"
,
@"
&(lt|#60);
"
,
@"
&(gt|#62);
"
,
@"
&(nbsp|#160);
"
,
@"
&(iexcl|#161);
"
,
@"
&(cent|#162);
"
,
@"
&(pound|#163);
"
,
@"
&(copy|#169);
"
,
@"
&#(\d+);
"
,
@"
-->
"
,
@"
<!--.*\n
"
}
;
string
[] aryRep
=
{
""
,
""
,
""
,
"
\
""
,
"
&
"
,
"
<
"
,
"
>
"
,
"
"
,
"
\xa1
"
,
//
chr(161),
"
\xa2
"
,
//
chr(162),
"
\xa3
"
,
//
chr(163),
"
\xa9
"
,
//
chr(169),
""
,
"
\r\n
"
,
""
}
;
string
newReg
=
aryReg[
0
];
string
strOutput
=
strHtml;
for
(
int
i
=
0
;i
<
aryReg.Length;i
++
)
{
Regex regex
=
new
Regex(aryReg[i],RegexOptions.IgnoreCase );
strOutput
=
regex.Replace(strOutput,aryRep[i]);
}
strOutput.Replace(
"
<
"
,
""
);
strOutput.Replace(
"
>
"
,
""
);
strOutput.Replace(
"
\r\n
"
,
""
);
return
strOutput;
}
青苹果Web应用商店
https://webapp.taobao.com/
PHP/ASP.NET/ASP/UCHOME/DISCUZ! X系列网站开发,详细需求联系
QQ:8511978
查看全文
相关阅读:
Flink 架构和拓扑概览
Flink 如何背压
流式计算的时间模型
流式计算的背压问题
大数据流式计算容错方案演进之路
Flink 任务提交
Flink wordCount
线性回归和逻辑回归的区别
Nginx反向代理后配置404页面
Httpclient 实现带参文件上传
原文地址:https://www.cnblogs.com/Dicky/p/122372.html
最新文章
CF915E Physical Education Lessons
LuoguP2824 [HEOI2016/TJOI2016]排序
LuoguP3521 [POI2011]ROT-Tree Rotations
[BZOJ4152]4152: [AMPPZ2014]The Captain
弹性盒子侧轴对齐方式
jquery对象与核心函数
初识jquery
div居中方式
数组之reduce()和reduceRight()
转换字符串方法、判断数组类型
热门文章
css3之弹性盒模型初探(一)
数组过滤与逻辑判断
数组剪切与索引位置
CSS3之盒模型
JS拖拽事件
ios8铃声
《亲爱的》小孩
岁月的流逝,注定我们的成长
光辉岁月女生版-国语-雷婷
Flink ADD Multi Source
Copyright © 2011-2022 走看看