请问如何清除HTML的各种格式?

html-css016

请问如何清除HTML的各种格式?,第1张

在网页里面复制你要的内容,然后粘贴到WORD里面就可以清除样式,或者是把网页另存,用WORD打开,会出现加载错误,xxx.css文件丢失,自然就没有那些样式了,不能粘贴到txt,这样的话连接就会没有了

不知道你的需求是什么,但是这个列表的原点这样去掉。

这个没有圆点的:

<style>

.list{list-style-type:none}

</style>

<ul class='list'>

    <li>1</li>

    <li>2</li>

    <li>3</li>

    <li>4</li>

    <li>5</li>

</ul>

有圆点的:

<ul>

    <li>1</li>

    <li>2</li>

    <li>3</li>

    <li>4</li>

    <li>5</li>

</ul>

PHP清除html、css、js格式并去除空格的PHP函数

01function cutstr_html($string,$length=0,$ellipsis='…'){

02$string=strip_tags($string)

03$string=preg_replace('/\n/is','',$string)

04$string=preg_replace('/ | /is','',$string)

05$string=preg_replace('/ /is','',$string)

06preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/",$string,$string)

07if(is_array($string)&&!empty($string[0])){

08if(is_numeric($length)&&$length){

09$string=join('',array_slice($string[0],0,$length)).$ellipsis

10}else{

11$string=implode('',$string[0])

12}

13}else{

14$string=''

15}

16return $string

17}

php 去除html标签 js 和 css样式

01function clearHtml($content){

02$content=preg_replace("/<a[^>]*>/i","",$content)

03$content=preg_replace("/<\/a>/i","",$content)

04$content=preg_replace("/<div[^>]*>/i","",$content)

05$content=preg_replace("/<\/div>/i","",$content)

06$content=preg_replace("/<!--[^>]*-->/i","",$content)//注释内容

07$content=preg_replace("/style=.+?['|\"]/i",'',$content)//去除样式

08$content=preg_replace("/class=.+?['|\"]/i",'',$content)//去除样式

09$content=preg_replace("/id=.+?['|\"]/i",'',$content)//去除样式

10$content=preg_replace("/lang=.+?['|\"]/i",'',$content)//去除样式

11$content=preg_replace("/width=.+?['|\"]/i",'',$content)//去除样式

12$content=preg_replace("/height=.+?['|\"]/i",'',$content)//去除样式

13$content=preg_replace("/border=.+?['|\"]/i",'',$content)//去除样式

14$content=preg_replace("/face=.+?['|\"]/i",'',$content)//去除样式

15$content=preg_replace("/face=.+?['|\"]/",'',$content)//去除样式 只允许小写 正则匹配没有带 i 参数

16return $content

17}