如何将以下的字符中 <TD sytle=****** >替换成 <TD>
<TD
style="BORDER-RIGHT: black 1pt solid; PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: black 2.25pt double; WIDTH: 115.05pt; BORDER-TOP-COLOR: #c0c0c0; PADDING-TOP: 0cm; BORDER-BOTTOM: black 1pt solid; HEIGHT: 14.2pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid black .75pt; mso-border-top-alt: solid black .75pt; mso-border-left-alt: double black 2.25pt"
width=153>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; LINE-HEIGHT: 12pt; mso-line-height-rule: exactly"><SPAN
lang=EN-US style="FONT-SIZE: 9pt; mso-bidi-font-size: 12.0pt"><FONT
face="Times New Roman"><FONT
color=#000000>6148CH<o:p></o:p></FONT></FONT></SPAN></P></TD>
帮顶
你可以用正则表达式来做,我也在学习这个东东,不过还没有学会就不多说,下面的高手帮一帮忙了。
不过这个东东还是很不好学的。努力,关注!!!!,学习。
preg_replace("/\<td.*\>/Usi","<td>",$str);
先找<TD,再从这个位置开始找>,找到后把整段内容REPLACE成<TD>
<button onclick="vbs:gogogo">开始处理</button><br/>
csdnFAQ转换txt格式专用工具:<br/>
<SCRIPT LANGUAGE="vbscript">
**************************
*****超级大笨狼***********
**************************
on error resume next
window.resizeTo window.screen.availWidth,window.screen.availHeight
window.moveTo 0,0
Set fso = CreateObject("Scripting.FileSystemObject")
dim thisFileDir定义本文件绝对路径
dim thisFileName定义本文件名
dim thisFileFolder定义本文件夹路径
dim regEx
set regEx = new RegExp
regEx.Global = true
thisFileDir = replace(window.location.href,"file:///","")
thisFileDir = unescape(replace(thisFileDir,"/","\"))
thisFileName = LastOne(thisFileDir,"\")
thisFileFolder=getFolderDir(thisFileDir)
currentDir = thisFileFolder
function HTMLfilter(str)
去掉开始到Q:间的东西
regEx.Pattern = "<HTML>[\w\W]*Q :</b>"
str = regEx.Replace(str, "")
str = replace(str,"<br>" ,vbcrlf)
regEx.Pattern = "<[^<>]*>"
str = regEx.Replace(str, "")
str = replace(str," " ," ")
str = replace(str,">",">")
str = replace(str,"<","<")
str = replace(str,""",chr(34))
str = replace(str,vbtab ,"")
str = replace(str,"&","&")
regEx.Pattern = "[\s]*主要解答者:[\w\W]*查看[\s]*"
str = regEx.Replace(str, vbcrlf)
regEx.Pattern = "[\s]*网站简介[\w\W]*All rights reserved[\s]*"
str = regEx.Replace(str, "")
regEx.Pattern = "(^\s*)|(\s*$)"
str = regEx.Replace(str, "")
HTMLfilter = trim(str)
end function
function getFolderDir(fullDir)
输入得到全路径,得到文件夹路径
s=LastOne(fullDir,"\")
getFolderDir = left(fullDir,len(fullDir)-len(s))
end function
Function LastOne(Str,splitStr)
输入字符和分隔符,得到最后一部分
LastOne = right(Str,len(Str)-InStrRev(Str,splitStr))
End Function
sub seachFile(theFolder)
dim f,f1,st,fd,fd1,t
set f = fso.GetFolder(theFolder)
for each f1 in f.Files
if lcase(right(f1.name,4))=".htm" then
set st = fso.OpenTextFile(f1,1,1)
全读
if not st.AtEndOfStream then
t=st.readAll
set st = fso.OpenTextFile(getName(f1.name),2,1)
t=HTMLfilter(t)
st.write t
end if
end if
next
set fd = fso.GetFolder(theFolder)
for each fd1 in fd.SubFolders
seachFile fd1
next
end sub
sub gogogo()
seachFile thisFileFolder
alert "处理完毕"
end sub
function getName(x)
dim Arr,a,newName
newName=x
Arr=array("/","\",":","*","?",chr(34),"|","<",">",chr(39))
for each a in Arr
newName=replace(newName,a,"")
next
getName=replace(newName,".htm",".txt")
end function
</script>