How can asp implement the intercepting string function? I believe many people will be curious about this issue. So let’s take a look at the implementation method of asp intercepting string functions. Friends who don’t know, let’s take a look.
If the title is too long, because of the page layout limitation, you can only list 10 characters, this function will help you achieve it
The code copy is as follows:'Intercept string strvalue (title, word count)
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
p_num=int(p_num) + 2
else
p_num=int(p_num) + 1
end if
strvalue=left(trim(str),x)&"…"
loop
end if
end function
function strlen(str)
dim page_len
page_len=0
strlen=0
if trim(str)<>"" then
page_len=len(trim(str))
for xx=1 to page_len
if asc(mid(str,xx,1))<0 then
strlen=int(strlen) + 2
else
strlen=int(strlen) + 1
end if
next
end if
end function
How to use:
The code copy is as follows:<%=strvalue("Accurate programming language, can correctly color code syntax, enter a few simple words of code snippet description", 10)%>
The above is the implementation method of asp intercepting string functions. The code is very concise and practical. Friends who need it can refer to it.