数据库中表information中的content字段存储了带有html格式的文本,例如“ <Pstyle="TEXT-INDENT:2em">所谓性价比就是车辆的性能、配置、外形等综合指标与车辆售价的比值。即:性价比=性能+配置+外形+售价。</P><CENTER><IMGsrc="http://cimg2.163.com/catchp.jpg/>.....”现在想把他们从数据库中取出,并且去掉这些带有格式的标签,以上面的为例,取出后为“所谓性价比就是车辆的性能、配置、外形等综合指标与车辆售价的比值。即:性价比=性能+配置+外形+售价。”各位帮忙了,利马揭帖
'Strips the HTML tags from strHTML
Dim objRegExp, strOutput
Set objRegExp = New RegexpobjRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<.+?>"'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")'Replace all < and > with < and >
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")stripHTML = strOutput 'Return the value of strOutputSet objRegExp = Nothing
End Function
**************************************************************
Function stripHTML2(strtext)
dim arysplit,i,j, strOutput
arysplit=split(strtext,"<")if len(arysplit(0))>0 then j=1 else j=0for i=j to ubound(arysplit)
if instr(arysplit(i),">") then
arysplit(i)=mid(arysplit(i),instr(arysplit(i),">")+1)
else
arysplit(i)="<" & arysplit(i)
end if
nextstrOutput = join(arysplit, "")
strOutput = mid(strOutput, 2-j)
strOutput = replace(strOutput,">",">")
strOutput = replace(strOutput,"<","<")stripHTML = strOutput
End Function
try {
ResultString = Regex.Replace(SubjectString, "<[^>]*>", "");
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}