Recommendation: Interpretation of using ASP to write code similar to search engine functions First, build an access database. There is a URLINDEX table in the database, in which indexes are added to the URL and Keywords fields respectively, as follows: URL text (index: yes (no duplication)) Title text Description text Summary text Keywords text (index: yes (no) Repeat)) Program file doquery.asp, code: HTMLHEADTITLE simple search engine
We often see that when left is used to cut a string directly, because Chinese characters and English characters coexist in the title, the length of the two news titles is different. In order to solve this problem, we can use the following function. <% '************************************************ * 'Function name: gotTopic 'Function: truncate the string, each Chinese character counts as two characters, and the English character counts as one character 'Parameter: str----original string 'strlen---- intercept length 'Return value: intercepted string 'Copyright: asp tutorial '************************************************ * FunctiongotTopic(ByValstr,ByValstrlen) Ifstr=Then gotTopic= ExitFunction EndIf Diml,t,c,i,strTemp str=Replace(Replace(Replace(Replace(str,,),,Chr(34)),>,>),<,<) l=Len(str) t=0 strTemp=str strlen=CLng(strlen) Fori=1Tol c=Abs(Asc(Mid(str,i,1))) Ifc>255Then t=t+2 Else t=t+1 EndIf Ift>=strlenThen strTemp=Left(str,i) ExitFor EndIf Next IfstrTemp<>strThen strTemp=strTemp&… EndIf gotTopic=Replace(Replace(Replace(Replace(strTemp,,),Chr(34),),>,>),<,<) EndFunction %> <% str=A total of 11111w has Chinese characters str1=There are five Chinese characters in total response.writegotTopic response.writegotTopic(str,10)& &gotTopic(str1,10)& response.writeleft response.writeLeft(str,5)& &Left(str1,5) response.end %> |
Share: Reveal the method to solve the problem of accidentally deleting asp files by anti-virus software Some anti-virus software often delete certain ASP files as viruses. Sometimes it is impossible to prevent them, and the program cannot be used inexplicably because the files are missing~~. This is mainly because anti-virus software treats certain ASP codes as Trojan horse keywords and saves records. Therefore, when encountering this keyword, it will be prohibited from running or deleted. The solution is to give these keywords