你的位置:| 首页网站建设过滤空格 回车 制表符→文章正文  
文章导航

过滤空格 回车 制表符

Function GetContent(str,start,last,n)

If Instr(lcase(str),lcase(start))>0 and Instr(lcase(str),lcase(last))>0 then
select case n
case 0 '左右都截取(都取前面)(去处关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))-1)
case 1 '左右都截取(都取前面)(保留关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
GetContent=Left(GetContent,Instr(lcase(GetContent),lcase(last))+Len(last)-1)
case 2 '只往右截取(取前面的)(去除关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))-Len(start)+1)
case 3 '只往右截取(取前面的)(包含关键字)
GetContent=Right(str,Len(str)-Instr(lcase(str),lcase(start))+1)
case 4 '只往左截取(取后面的)(包含关键字)
GetContent=Left(str,InstrRev(lcase(str),lcase(start))+Len(start)-1)
case 5 '只往左截取(取后面的)(去除关键字)
GetContent=Left(str,InstrRev(lcase(str),lcase(start))-1)
case 6 '只往左截取(取前面的)(包含关键字)
GetContent=Left(str,Instr(lcase(str),lcase(start))+Len(start)-1)
case 7 '只往右截取(取后面的)(包含关键字)
GetContent=Right(str,Len(str)-InstrRev(lcase(str),lcase(start))+1)
case 8 '只往左截取(取前面的)(去除关键字)
GetContent=Left(str,Instr(lcase(str),lcase(start))-1)
case 9 '只往右截取(取后面的)(包含关键字)
GetContent=Right(str,Len(str)-InstrRev(lcase(str),lcase(start)))
end select
Else
GetContent=""
End if

End function
'过滤空格 回车 制表符
Function filtrate(str)
str=replace(str,chr(13),"")
str=replace(str,chr(10),"")
str=replace(str,chr(9),"")
filtrate=str
End Function

'====================asp=======================

<%
'----------Html转换为文本:编辑时拿来做转换
Function Html2Text(Str1)
If isNULL(Str1) Then
Html2Text=""
Exit Function
End If
Str1=Replace(Str1,"&lt;"," <")
Str1=Replace(Str1,"&gt;",">")
Str1=Replace(Str1,"<br>",VBcrlf)
Str1=Replace(Str1,"&quot;",chr(34))
Str1=Replace(Str1,"&nbsp;"," ")
Str1=Replace(Str1,"&amp;","&")
Html2Text=Str1
End Function
'-------------------文本转换为Html:写入数据库时使用---------------
Function Text2Html(Str1)
If isNULL(Str1) Then
Text2Html=""
Exit Function
End If
Str1=Replace(Str1,"&","&amp;")
Str1=Replace(Str1," <","&lt;")
Str1=Replace(Str1,">","&gt;")
Str1=Replace(Str1,VBcrlf,"<br>")
Str1=Replace(Str1,chr(34),"&quot;")
Str1=Replace(Str1,chr(9),"&nbsp;&nbsp;&nbsp;")
Str1=Replace(Str1," ","&nbsp;")
Text2Html=Str1
End Function
%>

使用方法:

调用上面的文件再在表单中要显示的地方调用过程函数(Html2Text)

<textarea name="naiyong" cols="88" rows="18" wrap="on" class="editbox2" id="naiyong"><%=Html2Text(rs("naiyong"))%></textarea>

  上一页 1 2 3 4 5 下一页