ASP字数控制

来源:百度知道 编辑:UC知道 时间:2024/09/23 21:24:38
<%small_classid=request("small_classid")
SQLStr = "select * from web_menu where small_ClassID=505 order by id desc"
Set Rs = Conn.Execute (SQLStr)
if not rs.eof or not rs.bof then
response.write rs("content")
else
response.write "没有填写!"
end if
%>

这样的代码中如果控制字数??

要想办法先把HTML代码去除再计算

if not rs.eof or not rs.bof then
if len(rs("content"))>20 then
response.write left(rs("content"),18)&"..."
else
response.write rs("content")
end if
else
response.write "没有填写!"
end if

<%
Function RemoveHTML( strText )
Dim RegEx

Set RegEx = New RegExp

RegEx.Pattern = "<[^>]*>"
RegEx.Global = True

RemoveHTML = RegEx.Replace(strText, "")
End Function

small_classid=request("small_classid")
SQLStr = "select * from web_menu where small_ClassID=505 order by id desc"
Set Rs = Conn.Execute (SQLStr)
if not rs.eof or not rs.bof then
response.write left( RemoveHTML(rs("content")),18)'18个字
else
response.write "没有填写!"
end if
%>