Recommended: How to use InstrRev() to get file name in asp The InstrRev function starts from the last search of the string, and is the preceding string. % Dim strTXT,pos strTXT=www.webjx.com pos=instrRev(strTXT,.) Response.Write pos % The beginning of our search is in reverse order, from a point before com. The length of the starting character, including this point, has ten characters in total, and the result returned will be 9. pass
<html> <head> <http-equiv=Content-Type content=text/html; charset=gb2312> <title></title> </head> <body> <% LANGUAGE = VBScript % > <% Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 Dim filename filename = test.txt 'The default relative path is c:winnt Set fs = CreateObject(Scripting.FileSystemObject) Set f = fs.GetFile(filename) Set readf = f.OpenAsTextStream(ForReading,TristateFalse) 'The first parameter is optional. Input/output mode is one of the following three constants: ' ForReading=1 read-only, ForWriting=2 read-write or ForAppending=3 append 'The second parameter is also optional. One of the three Tristate values, ' Indicate in which format the file is opened. Ignore this parameter and the file is ASCII 'The format is open. TristateUseDefault=-2 Open the file in the system default format, 'TristateTrue=-1 Open the file in Unicode format or TristateFalse=0 'Open the file in ASCII format. 'You can also use the OpenTextFile method to open the file s = readf.ReadLine Do While readf.AtEndOfLine <> True s = readf.ReadLine Response.write s & 'Read the file line by line and write it out Loop readf.close %> </body> </html> |
Share: A fuzzy query syntax that is faster than like clauses Generally speaking, when using fuzzy queries, everyone will think of LIKE select * from table where a like '%character%' If multiple like fuzzy queries are used in a SQL statement and the number of records is large, the speed will definitely be very slow. The following two methods can also implement fuzzy query: select * from table where patindex('%character%',a)0 sele