This article provides the ASP string intercept function is the first to use the definition of string discriminant function to determine the length of the string and Chinese and English, and then intercept the characters after the definition beyond the content of ... Display mode
function strvalue (str,lennum)
dim P_num
dim I
if strlen (str) <=lennum then
strvalue=str
else
p_num=0
x=0
do While not p_num > Lennum-2
x=x+1
if ASC (Mid (str,x,1)) <0 then
&nBsp; p_num=int (P_num) + 2
else
p_num=int (p_num) + 1
end if
strvalue=left (Trim (str), x) & "..." ' After intercepting the display of the content beyond the definition
loop
end if
end function
' Define string discriminant functions
function strlen (str)
dim P_len
p_len=0
strlen=0
if trim (str) <> "" Then
p_len=len ((str))
for xx=1 to P_len
if ASC (Mid (str,xx,1)) <0 then
strlen=int (strlen) + 2
else
strlen=int (strlen) + 1
& nbsp; end if
next
end If
end function
' intercepts the string, 1. Includes front and back strings, 2. Do not include before and after strings
function Strcut (Strcontent,startstr,endstr,cuttype)
dim s1,s2
on Error Resume Next
select Case Cuttype
case 1
s1 = InStr ( STRCONTENT,STARTSTR)
s2 = InStr (S1,STRCONTENT,ENDSTR) +len (endstr)
case 2
s1 = InStr (strcontent,startstr ) +len (startsTR)
s2 = InStr (S1,strcontent, ENDSTR)
end Select
if Err then
strcute = "<p align= ' center ' ><font size=-1> intercepting string error. </font></p >
err.clear
Exit Function
else
strcut = Mid (strcontent,s1,s2-s1)
end if
end function